[Fontconfig] any possible trouble by adding lang to the pattern by default

Akira TAGOH akira at tagoh.org
Wed May 30 05:19:09 PDT 2012


On Wed, May 30, 2012 at 8:26 PM, Jjgod Jiang <gzjjgod at gmail.com> wrote:
> I'm struggling to understand how to I specify a preferred font list for
> certain languages. Let's say I want to make sure my preferred order for
> "zh" font is like this:
>
>   Hiragino Sans GB
>   STHeiti
>   Adobe Heiti Std
>   Droid Sans Fallback
>   Microsoft YaHei
>
> But I do *not* want to specify a hardcoded lang in my FcPattern, I'd
> rather have FcDefaultSubstitue() to add the default lang for me based
> on current environment. If I specify the preferred zh font list like
> this:
>
>   <match target="pattern">
>      <test name="lang"><string>zh</string></test>
>      <edit name="family" mode="append" binding="same">
>         <string>Hiragino Sans GB</string>…
>      </edit>
>   </match>
>
> then this will happen in FcConfigSubstitute() which is (normally)
> earlier than FcDefaultSubstitute(), then I don't get the lang set
> by FcDefaultSubstitute().
>
> So what's the preferred way to do that?

Well, the rule itself roughly looks good. in theory, the lang should
be added to the pattern in applications according to their
requirements to render the text. however they don't necessarily do
that because there are no way to figure out etc. this typically
happens when the application render non-rich text like the plain text.

The changes in the subject is to improve matching the font in even
that case. and my answer to the question in the previous mail was why
I've added the logic to add the lang even though the similar code was
available in FcDefaultSubstitute().

So for your question, what you need to do to get the preferred fonts
for the certain language is to set the language to FC_LANG as needed,
you should do particularly if you have complicated things on the
locale settings. otherwise it should just works. it may be easy to
understand once you try it :)

HTH,
-- 
Akira TAGOH


More information about the Fontconfig mailing list