[Fontconfig] FcPatternGet always gives font weight of '0'

Lucien Gentis lucien.gentis at waika9.com
Thu Sep 12 16:25:42 UTC 2019


I'm back !

XftFontOpenName calls FcNameParse, and its this function which returns 
an FcPattern whose FC_WEIGHT property has type FcTypeDouble

So it's Fontconfig related.

Fontconfig ChangeLog says that FC_WEIGHT is yet of type range, but it's 
returned by FcPatternGet as double ???

Nevermind, in my real program, I replaced all occurences of 
"fcValue.u.i" by "(int)(fcValue.u.d)" when it's font weight related, and 
it works again.

Le 11/09/2019 à 15:24, Lucien Gentis a écrit :
> I found the origin of the problem.
>
> It's in XftFontOpenName function I use to generate an XftFont 
> structure that contains an FcPattern.
>
> FC_WEIGHT property of this FcPattern has type double instead of integer.
>
> If I use:
>
> FcPatternGet(font->pattern,FC_WEIGHT,0,&fcValue);
>
> fcValue has type FcTypeDouble , and its value fcValue.u.d is 200,000 , 
> that matches expected integer value for "bold" !
>
> So it's not a fontconfig problem, it's an Xft one !
>
> Thanks for reading
>
> Lucien
>
> Le 11/09/2019 à 01:35, Lawrence D'Oliveiro a écrit :
>> On Tue, 10 Sep 2019 14:36:48 +0200, Lucien Gentis wrote:
>>
>>> 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
>> There was a version of Fontconfig that stopped recognizing “bold” as a
>> value for the “weight” property for a while. I run Debian Unstable, and
>> as I recall this did get fixed, but it looks like the previous version
>> was left in Stable for version 10.
>>
>> As a workaround, try “weight=200” in your 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