1. Origin:
VCU10 project uses Noto Sans font, which is indeed beautiful. However, when verified under win7, the Korean text displayed is garbled, which is quite a headache.
The interface is displayed as shown in the figure:
##Du Niangzhi, Noto Sans and CJK fonts, as the name suggests, it supports Chinese, Japanese and Korean, and its It’s huge and not suitable as a plan, so keep thinking!2. Font.GdiCharSet attribute
There is no way. Based on the current situation, can the problem be solved? The program needs to support multiple languages. Let’s start with the properties of the font itself. The verification found that by changing its character set GdiCharSet, Korean can be displayed normally. The solution is there! After consulting the information, we learned that the font GdiCharSet can have the following values:##Character set
| Value|
---|---|
ANSI
|
0
|
##1 |
|
2 |
|
128 |
|
##129 |
##North Korea Language |
129 |
##GB2312 |
134 |
##CHINESEBIG5 Applicable |
136
|
OEM |
255
|
##Korean |
|
##Hebrew
|
|
Arabic
| ##178
##Turkish |
##162 |
##Vietnamese |
##163 |
##Thai
|
222
|
204 |
|
##77 |
##Baltic |
186 |
It was verified that character sets such as Eastern Europe and Baltic Sea can display Korean normally without affecting the display effect of its default character set, so it was decided to replace its character set. |
3. Replace The project interface has set fonts, and there are many interfaces. Of course it is not convenient to change them one by one. Write code to process them in batches. ! | In each form or each UserControl, call UpdateNotoSansCharset() and the numbers will be replaced uniformly.
//处理Label字体,以能在win7下,NotoSans字体能显示韩文public static void UpdateNotoSansCharset(Form form) {if (OSUtils.OSVersion > FriendlyOSVersion.Win7)return;foreach (Control ctrl in form.Controls) UpdateNotoSansCharset(ctrl); }public static void UpdateNotoSansCharset(ScrollableControl parent) {if (OSUtils.OSVersion > FriendlyOSVersion.Win7)return;foreach (Control ctrl in parent.Controls) UpdateNotoSansCharset(ctrl); }public static void UpdateNotoSansCharset(GControl ctrl) {if (ctrl is ScrollableControl) UpdateNotoSansCharset(ctrl as ScrollableControl);else if (ctrl is Label) {//CharSet采用中欧字符集var font = new Font(ctrl.Font.FontFamily, ctrl.Font.Size, ctrl.Font.Style, ctrl.Font.Unit, 238); ctrl.Font = font; } } Copy after login |
OK, the problem is solved, perfect:
The above is the detailed content of Example tutorial on supporting Korean in Noto Sans font in c#. For more information, please follow other related articles on the PHP Chinese website!