简体   繁体   中英

.ttf font priority in Qt

Work on Linux and using Qt Framework. All .ttf fonts are in the /usr/lib/fonts/. If I keep both Japanese and Chinese in this folder, the Japanese will use the Chinese font; If Chinese font is removed, Japanese font can be displayed properly, so I think it's a priority issue.

And I also notice a post online talking about how to use fontconfig to fix this problem. However, there isn't font.conf under apps/fontconfig-2.8.0/src/conf.d, instead it has lots of .conf like:

10-autohint.conf
10-no-sub-pixel.conf
10-sub-pixel-bgr.conf
10-sub-pixel-rgb.conf
10-sub-pixel-vbgr.conf
10-sub-pixel-vrgb.conf
10-unhinted.conf
20-fix-globaladvance.conf
20-unhint-small-vera.conf
25-unhint-nonlatin.conf
30-metric-aliases.conf
30-urw-aliases.conf
40-nonlatin.conf
45-latin.conf
49-sansserif.conf
50-user.conf
51-local.conf
60-latin.conf
65-fonts-persian.conf
65-khmer.conf
65-nonlatin.conf
69-unifont.conf
70-no-bitmaps.conf
70-yes-bitmaps.conf
80-delicious.conf
90-synthetic.conf

So which one should I use?

BTW, fc-list always gives nothing for me.

Any help and hint will be greatly appreciated.

There is no specific file to use, they are evaluated in naming order so a directive in 10-foo.conf will be read before a directive in 90-bar.conf. However the configuration language allow overrides, so earlier is not always stronger. On modern fontconfig installations you will often find rules like "if the locale is Japanese prefer Japanese fonts" and they only work if evaluated last.

Usually you get the problem you describe when your app/environment is not providing a target locale to the font system. Given unicode han unification the font system can not infer if you want Japanese of Chinese-style glyphs from the codepoints, it needs to be told explicitly. So if you're doing something like forcing an en_US locale instead of using a Chinese or Japanese one, you've got at least 50% chance the system will get it wrong.

And then even if you do declare the correct locale all apps will not propagate it correctly to the font stack, that's all bugs to fill.

There is no short or easy solution: make sure you are not lying about your locale to the system, get your locale fixed if you can't stand it, fill bugs on apps that still do not apply it.

The alternative is to force a single style of rendering by uninstalling or hiding one of the font sets, but that will also break rendering for this language if you ever need to display it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM