First of all thank you for your help. I think I may have found the cause of the problem, but it’s hard to find a general solution.
openfl provides three sets of default fonts, namely “_sans”, “_serif” and “_typewriter”, and haxeui-openfl uses the “_sans” font
haxeui-openfl/haxe/ui/backend/openfl/_module/styles/main.css at master · haxeui/haxeui-openfl (github.com)
.label, .textfield, .textarea {
font-size: 13px;
__font-name: "_sans";
}
However, the default font of openfl only has English characters.
openfl/src/openfl/text/_internal/TextEngine.hx at develop · openfl/openfl (github.com)
#if windows
__defaultFonts.set("_sans",
new DefaultFontSet(findFont(systemFontDirectory + "/arial.ttf"), findFont(systemFontDirectory + "/arialbd.ttf"),
findFont(systemFontDirectory + "/ariali.ttf"), findFont(systemFontDirectory + "/arialbi.ttf")));
__defaultFonts.set("_serif",
new DefaultFontSet(findFont(systemFontDirectory + "/times.ttf"), findFont(systemFontDirectory + "/timesbd.ttf"),
findFont(systemFontDirectory + "/timesi.ttf"), findFont(systemFontDirectory + "/timesbi.ttf")));
__defaultFonts.set("_typewriter",
new DefaultFontSet(findFont(systemFontDirectory + "/cour.ttf"), findFont(systemFontDirectory + "/courbd.ttf"),
findFont(systemFontDirectory + "/couri.ttf"), findFont(systemFontDirectory + "/courbi.ttf")));
I can use the Windows system Chinese font in the code, but I cannot override the default “_sans” font of openfl.
openfl.text.Font.registerFont(openfl.text.Font.fromFile(lime.system.System.fontsDirectory + "\\simhei.ttf"));
<style>
.button { font-name: SimHei; }
</style>
Unfortunately, the default Chinese font on Windows is msyh.ttc, and openfl does not support the *.ttc format. Therefore, I cannot make the haxeui-openfl application display the same font as other windows applications.