1、源起:
VCU10項目,使用了Noto Sans字體,的確漂亮。但驗證在win7下,其顯示韓文為亂碼,頗為頭痛。
其介面顯示如圖:
度娘之,得Noto Sans又有CJK字體,顧名思義,其為支持中日韓文,且其體積巨大,不宜做為方案,繼續思考!
2、Font.GdiCharSet 屬性
也是沒有辦法,看在目前基礎上,能不能解決問題?程式多國語言需支援。
就從字體本身屬性開始檢查吧,驗證發現,改其字元集GdiCharSet,可正常顯示韓文,解決方案有了!
查閱資料得知,字體GdiCharSet可有以下值:
字元集 | 值 |
---|---|
ANSI | 0 |
DEFAULT | 1 |
##韓文 | 129 |
##朝鮮語言 | 129 |
GB2312 | #134 |
#CHINESEBIG5 適用 | |
##136 | |
#OEM | |
##OEM | 255 |
韓文 | 130
|
希伯來文 | #177
|
阿拉伯文 | #178 |
越南語 | |
#EASTEUROPE | |
#俄語 |
##204
//处理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; } }###### ###### ###4、效果#########OK,難題解決,非常完美:######## ####
以上是c#中Noto Sans字體支援韓文的實例教程的詳細內容。更多資訊請關注PHP中文網其他相關文章!