随着全球化的发展,开发软件都是面向多语言的环境。目前大多数程序都是采用不同字体来显示不同语言的办法,那么有没有一种更好的办法,一种字体就可以解决全球语言的显示呢?答案肯定的,它就是采用逻辑字体MS Shell Dlg和MS Shell Dlg2。比如开发应用程序时,就看到在资源里可以设置MS Shell Dlg和MS Shell Dlg2作为字体,并且可以设置不同的语言标识号,这样一个应用程序里就可以包括N种语言的资源,当这个应用程序运行在不同本地化设置地区时,操作系统就可以根据当前语言标识号去查找应用程序里的资源,如果找到一致的语言标识时就可以使用这种资源来显示。这时操作系统,就会使用注册表里标记为MS Shell Dlg和MS Shell Dlg2相对应的字体文件作为应用程序里的文字显示出来。ReactOS里就是使用这种方式来显示中文界面的。可以看到ReactOS注册表里如下:
70 [Font.CJK.Reg]
71 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","Arial",0x00000000,"Liberation Sans"
72 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","Courier",0x00000000,"FreeMono"
73 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","Courier New",0x00000000,"FreeMono"
74 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","Times New Roman",0x00000000,"Liberation Serif"
75 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","Tahoma",0x00000000,"Droid Sans Fallback"
76 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","MS Sans Serif",0x00000000,"Tahoma"
77 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","MS Shell Dlg",0x00000000,"Droid Sans Fallback"
78 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","MS Shell Dlg 2",0x00000000,"Droid Sans Fallback"
79 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","MS UI Gothic",0x00000000,"Droid Sans Fallback"
80 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","MS UI Gothic 2",0x00000000,"Droid Sans Fallback"
81 HKLM,"SOFTWARE/Microsoft/Windows NT/CurrentVersion/SysFontSubstitutes","Helv",0x00000000,"Tahoma"
在这里设置的字体为Droid Sans Fallback,是否很眼熟呢?是的,它就是Google的android字体,在小小的3M大小的文件里包括CJK基本的字体显示,缺省的字在文泉驿里也添加了不少,如果要显示多的字,就需要替换为它了。当在ReactOS编译过程制作安装包时,就会从reactos/boot/bootdata/packages/reactos.dff里拷贝字体到ISO文件里。在安装时可以选择这种字体,就是修改下面这段代码:
62 MUI_SUBFONT CJKFonts[] =
63 {
64 { L"Arial", L"Liberation Sans" },
65 { L"Courier", L"FreeMono" },
66 { L"Courier New", L"FreeMono" },
67 { L"Times New Roman", L"Liberation Serif" },
68 { L"Tahoma", L"Droid Sans Fallback" },
69 { L"MS Sans Serif", L"Tahoma" },
70 { L"MS Shell Dlg", L"Droid Sans Fallback" },
71 { L"MS Shell Dlg 2", L"Droid Sans Fallback" },
72 { L"MS UI Gothic", L"Droid Sans Fallback" },
73 { L"MS UI Gothic 2", L"Droid Sans Fallback" },
74 { L"Helv", L"Tahoma" },
75 { NULL, NULL }
76 };
和
168 {L"00000404", L"950", L"950", L"10008", L"Chinese (Taiwan)", L"886", enUSPages, enUSErrorEntries, enUSStrings, CJKFonts, zhTWLayouts },
169 {L"00000804", L"936", L"936", L"10008", L"Chinese (PRC)", L"86", enUSPages, enUSErrorEntries, enUSStrings, CJKFonts, zhCNLayouts },
170 {L"00000C04", L"950", L"950", L"10008", L"Chinese (Hong Kong S.A.R.)", L"1", enUSPages, enUSErrorEntries, enUSStrings, CJKFonts, zhHKLayouts },
通过上面的修改,就可以让 ReactOS 支持 CJK 的字体显示了。