Open 0tkl opened 8 months ago
I'm really not sure we can do anything about this, our wxFONTFAMILY_SWISS
maps directly to Win32 FF_SWISS
and if Windows selects an inappropriate font in this case, it probably indicates that the font describes itself incorrectly or something else outside of our control. I.e. I'm almost certain that if you write a simple program doing the same thing using Win32 API directly, the results would be the same. Of course, if you can actually test this and this turns out not to be the case, please let us know, but otherwise I think this is out of scope for wx.
And if you want to use a precise font, the best is really to let the user choose it and then save it using wxFont::GetNativeFontInfoDesc()
for the subsequent runs.
I assume wxFONTFAMILY_DEFAULT, by semantics, equals to “system UI font on user's device”.
Try this progam. In my device, it outputs the expected fonts across locales (Segoe UI, YaHei UI, JhengHei UI, Yu Gothic UI, Malgun Gothic…). The core thing is:
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
Font default_font(hdc, &(ncm.lfMessageFont));
This solution had been used in Chromium. I just learned this solution from StackOverflow.
If assuming the UI font of all supporting operating systems are all sans-serifs, then SWISS can be mapped to DEFAULT.
I assume wxFONTFAMILY_DEFAULT, by semantics, equals to “system UI font on user's device”.
Actually this would be wxNORMAL_FONT
(which uses the "solution from SO" for ~15 years, since 16b0c553987). wxFONTFAMILY_DEFAULT
is not very useful, admittedly...
If assuming the UI font of all supporting operating systems are all sans-serifs, then SWISS can be mapped to DEFAULT.
I have no idea whether system default font is always sans-serif and I'm pretty sure that you can change it to a serif font if you want to, so this definitely seems wrong to me.
Description
Bug description:
In various system locales, text defined with wxFONTFAMILY_* may not displayed in expected styles.
Expected vs observed behaviour:
微软雅黑 / Microsoft YaHei (Until Windows 7)
微软雅黑 / Microsoft YaHei (Until Windows 7)
微軟正黑體 / Microsoft JhengHei (Until Windows 7)
微軟正黑體 / Microsoft JhengHei (Until Windows 7)
Meiryo UI (Until Windows 8.1)
MS PMincho (Until Windows 8 or Vista)
Meiryo UI (Until Windows 8.1)
To Reproduce:
Build the code and run in English, Chinese Simpified, Chinese Traditional, Japanese and Korean locales respectively.
Platform and version information