[Fontconfig] FcPatternGet always gives font weight of '0'
Lawrence D'Oliveiro
ldo at geek-central.gen.nz
Mon Sep 9 22:52:59 UTC 2019
On Mon, 9 Sep 2019 18:11:03 +0200, Lucien Gentis wrote:
> const char * newFont="Liberation Sans:style=Bold Italic";
...
I think what you are seeing is the difference in the way Fontconfig
interprets different pattern specs. Using my Python binding
<https://github.com/ldo/python_fontconfig>, and recreating what you are
doing:
>>> f = fc.Pattern.name_parse("Liberation Sans:style=Bold Italic")
>>> f.get("family", 0)
('Liberation Sans', 0)
>>> f.get("style", 0)
('Bold Italic', 0)
>>> f.get("weight", 0)
(None, 1)
>>> f.get("slant", 0)
(None, 1)
The second number in the result tuples is the status code; the nonzero
value is FcResultNoMatch for the weight and slant. But if I write the
pattern this way:
>>> f = fc.Pattern.name_parse("Liberation Sans:weight=bold:slant=italic")
>>> f.get("family", 0)
('Liberation Sans', 0)
>>> f.get("style", 0)
(None, 1)
>>> f.get("weight", 0)
(200.0, 0)
>>> f.get("slant", 0)
(100, 0)
Now you see that the pattern has no style property, but it does have a
weight and slant. Because that is what I specified. The first variant
has a style, but no weight or slant, again because that is what I
specified.
Remember, this is just the search pattern. Once you use this to find an
actual font, you should get a lot more info back from the matching
instance pattern.
More information about the Fontconfig
mailing list