Comment 46 for bug 1468027

Revision history for this message
In , Mingye Wang (artoria2e5) wrote :

Many True/OpenType fonts, like Noto Sans CJK ("notocjk") in this example, uses a pattern in "name" table where:

* name.fontFamily gives the full name (with style) of the font and Subfamily is always Regular
* name.preferredFamily gives the actual family name and Subfamily is the actual weight

Fontconfig doesn't seem to be capable of handling such a case. Specifically, given a config file which <prefer>s notocjk:

        <alias>
                <family>sans-serif</family>
                <prefer>
                        <family>Noto Sans CJK SC</family>
                        <family>Noto Sans CJK TC</family>
                </prefer>
        </alias>

Fontconfig will produce a match like:

$ fc-match --verbose
Pattern has 38 elts (size 48)
        family: "Noto Sans CJK SC"(s) "Noto Sans CJK SC DemiLight"(s)
        familylang: "en"(s) "en"(s)
        style: "DemiLight"(w) "Regular"(w)
        stylelang: "en"(w) "en"(w)
        fullname: "Noto Sans CJK SC DemiLight"(w)
        fullnamelang: "en"(w)
        [...]

Now here is the problem. By preferring the preferredFamily "Noto Sans CJK SC", fontconfig ended up also preferring "Noto Sans CJK SC DemiLight", and matched "Noto Sans CJK SC DemiLight" "Regular" for the implicit "Regular".

See https://bugs.launchpad.net/ubuntu/+source/language-selector/+bug/1468027 for a context of this problem.