[Fontconfig] FcPatternGet always gives font weight of '0'
Lucien Gentis
lucien.gentis at waika9.com
Tue Sep 10 16:40:40 UTC 2019
In fact, I said something wrong: Ubuntu 18.04 and Debian have not the
same version of fontconfig:
fontconfig version under Ubuntu 18.04 is 2.12.6
fontconfig version under Debian 10 is 2.13.1
and something has changed for font weight between these two versions:
I looked at source code and saw that
fcobjs.h - version 2.12.6 says "FC_OBJECT (WEIGHT, FcTypeInteger,
FcCompareNumber)"
and that
fcobjs.h - version 2.13.1 says "FC_OBJECT (WEIGHT, FcTypeRange,
FcCompareRange)"
So I think it implies that WEIGHT is yet of type FcTypeRange
In this case, how to get weight property of a FcPattern ?
Le 10/09/2019 à 14:36, Lucien Gentis a écrit :
> Thanks for your reply, Mr D'Oliveiro
>
> So I tried to replace "Liberation Sans:style=Bold Italic" by
> "Liberation Sans:weight=bold:slant=italic" in my C program, but under
> Debian 10 , I still get:
>
> font family : Liberation Sans
> font weight : 0
> font slant : 100
>
> Family and slant are OK, only weight is false.
>
> Same program under Linux Ubuntu 18.04 gives :
>
> font family : Liberation Sans
> font weight : 200
> font slant : 100
>
> Le 10/09/2019 à 00:52, Lawrence D'Oliveiro a écrit :
>> 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.
>> _______________________________________________
>> Fontconfig mailing list
>> Fontconfig at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/fontconfig
> _______________________________________________
> Fontconfig mailing list
> Fontconfig at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/fontconfig
More information about the Fontconfig
mailing list