简体   繁体   English

.tf字体在Qt中的优先级

[英].ttf font priority in Qt

Work on Linux and using Qt Framework. 在Linux上使用Qt Framework。 All .ttf fonts are in the /usr/lib/fonts/. 所有.ttf字体都在/ 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. 我还注意到网上有一篇文章讨论如何使用fontconfig解决此问题。 However, there isn't font.conf under apps/fontconfig-2.8.0/src/conf.d, instead it has lots of .conf like: 但是,在apps / fontconfig-2.8.0 / src / conf.d下没有font.conf,而是有很多.conf,例如:

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. 顺便说一句,FC列表总是给我什么。

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. 没有要使用的特定文件,它们按命名顺序进行评估,因此将先读取10-foo.conf中的指令,再读取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. 在现代的fontconfig安装中,您经常会发现诸如“如果语言环境为日语,则首选日语字体”之类的规则,它们只有在最后一次评估后才能起作用。

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. 给定uni han统一,如果要从代码点获取日语的中文字形,则无法推断字体系统,因此需要明确告知。 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. 因此,如果您要执行某种强制使用en_US语言环境而不是使用中文或日语语言环境的操作,则系统至少有50%的机会会出错。

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. 另一种方法是通过卸载或隐藏一种字体集来强制使用一种渲染样式,但是如果您需要显示它,这也会破坏该语言的渲染。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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