Comment 25 for bug 167353

Revision history for this message
Stefan (stefan314) wrote :

I don't think Inkscape is able to do much about this issue.

The root of all problems probably is that pango doesn't use the font's style name to differentiate between the fonts but the weight, width and slant values. If you have fonts where the difference doesn't fit into these attributes, then pango cannot tell them apart. This is probably the case when using e.g. the Pochoir fonts (http://www.yanone.de/typedesign/pochoir/) which have a "Regular" and a "Sprayed" style (as I don't have the fonts I cannot check if the faces really are style linked, but you get the point). This can only be fixed at the pango level.

The second problem is caused by how Fontconfig handles style linked fonts. MS Windows can only handle four styles per family (Regular, Italic, Bold, Bold Italic), so families like e.g. the free "Yanone Kaffeesatz" (http://www.yanone.de/typedesign/kaffeesatz/) have their Regular and Bold weights style linked under a "Regular" family and have extra families for the lighter weights. However, the "preferred family" and "preferred style" are set to the real values so more sophisticated software (i.e. everything that is not MS Windows) is able to correctly style link them. Unfortunately Fontconfig doesn't just use the "preferred" names, but everything it finds and puts the "preferred" names in front of the list. For Kaffeesatz this results in:

Kaffeesatz Light:
  Family: "Yanone Kaffeesatz", "Yanone Kaffeesatz Light"
  Style: "Light", "Regular"
Kaffeesatz Regular:
  Family: "Yanone Kaffeesatz", "Yanone Kaffeesatz Regular"
  Style: "Regular", "Regular"

MS Windows sees the second value and shows them as two different families whith a "Regular" style, Mac OS sees the first value and shows them as one family with "Light" and "Regular" style. Fontconfig sees both, and when a font with Family="Yanone Kaffeesatz" and Style="Regular" is requested, it will find both fonts, because both have "Yanone Kaffeesatz" in the list of family names, and both have "Regular" in the list of style names. So it might happen that "Yanone Kaffeesatz Regular" is requested and "Yanone Kaffeesatz Light" really gets selected. This is a Fontconfig issue, but fixing it is easy. Put the following simple configuration snippet into /etc/fonts/fonts.conf:

<match target="scan">
    <edit name="family"><name>family</name></edit>
    <edit name="style"><name>style</name></edit>
</match>

Or put the attached file into /etc/fonts/conf.d or wherever Fontconfig will find it. Don't forget to run "fc-cache -f". Now Fontconfig discards everything after the first entry in the family and style lists of all fonts, so only the "preferred name" remains. This fixes most font selection issues.

What Inkscape could do is documenting the known font selection limitations and perhaps suggesting something like the above configuration snippet.