Comment 19 for bug 165521

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

I have had another look at this bug. There are a log of issues. Looking at Museo Sans Rounded with FontForge and some print statements inside Inkscape one finds:

Name PS Weight TTF Style Pango Pango Weight
100 Extra Light 100 300 Light
300 Light 300 300 Light
500 Normal 500 400 Normal
700 Semi Bold 700 600 Semi-Bold
900 Bold 900 700 Bold
1000 Black 1000 900 Heavy

Pango is using the PS Weight to determine the Pango/CSS weight. From looking at the Pango code, it seems that Extra Light should have a CSS value of 200. There appears to be a bug parsing the value in Pango. Inkscape keeps track of fonts using the Pango "Font Description" (PFD) which is based on CSS font properties. The duplication of weight 300 is the reason the Inkscape GUI shows only five weights when in fact their are six. This needs to be fixed in Pango.

Pango does have a function that returns a unique style name "suitable for displaying to users" for each face in a font family. In the case of Museo Sans Rounded the values are the same as in the 'Name' column above. Unfortunately, this information is not easily accessible inside Inkscape. It will take some hacking to make it available in our GUI (the argument to the function is a 'face' which is a temporary object that exists only when building the font map).

The long term solution has two parts. The first part is we should support CSS @font-face rules. With this, one can directly link a font resource (e.g. a font file) to a style. Then there is no guessing about which font face will be used. No substitution will be necessary. This will require a lot of work as it is not apparent (at least to me) on how to get Pango to support "User" fonts. The second part is to support the CSS Font Module Level 3 'font-variant' property. This allows choosing which glyphs to use out of a single font face. For example, instead of needing a separate font file for small-caps, the small-caps are in the same file as the regular glyphs. This is the current trend with font packaging and is the direction the HTML/CSS is heading.

As a final comment. Firefox, at least on Linux, uses Pango as a backend. It has the same bug with Museo Sans Rounded as Inkscape (showing five weight variants rather than six). But this is better than Chrome and Opera, which only display two weights.