[Fontconfig] Get width of each character.

Dheeraj Yadav dhirajyadav135 at gmail.com
Wed Feb 5 16:19:48 UTC 2020


Thanks!

On Wed, Feb 5, 2020, 9:45 PM Lucien Gentis <lucien.gentis at waika9.com> wrote:

> Hello Dheeraj,
> I think fontconfig.h does not provide any function calculating string or
> character width.
> But Xft.h does.
> You extract pertinent data from your FcPattern like family, size, slant,
> weight and for you spacing which must be 0.
> Then you open your font like this (example) :
>
> XftFont * font=XftFontOpenName(display,screen,newFont);
>
> where newFont could be "Liberation Sans-12:bold:roman:proportional"
>
> You can now calculate the width of the character 'm' via this command :
> XGlyphInfo glyphInfo;
> XftTextExtentsUtf8 (display,font,"m",1,&glyphInfo);
>
> glyphInfo.width contains the width of your character
>
>
> Le 05/02/2020 à 10:48, Dheeraj Yadav a écrit :
>
> DheerajHi Akira,
> Thanks for the reply.
>
> I know it doesn't affect rendering but I am working on converting text to
> pdf. So, I need to get the value of width of each character.
>
> Cheers
> Dheeraj
>
> On Wed, Feb 5, 2020, 2:58 PM Akira TAGOH <akira at tagoh.org> wrote:
>
>> On Wed, Feb 5, 2020 at 6:06 PM Dheeraj Yadav <dhirajyadav135 at gmail.com>
>> wrote:
>> >
>> > Hello everyone,
>> > The font I am using has FC_SPACING set as PROPORTIONAL.
>> > So, Width of each character is different. I wanted to know, is it
>> possible to get width of each character for a particular font in C i.e.
>> using fontconfig.h ?
>>
>> Even if you change a value in FC_SPACING property, that won't change
>> the feel of "Width of each character is different" because that is the
>> reason why it was PROPORTIONAL. that is just a cache from a font to
>> query a best font against a request. that won't affect the rendering
>> directly.
>>
>> >
>> > Thank you for your time.
>> >
>> > Cheers
>> > Dheeraj
>> > _______________________________________________
>> > Fontconfig mailing list
>> > Fontconfig at lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/fontconfig
>>
>>
>>
>> --
>> Akira TAGOH
>>
>
> _______________________________________________
> Fontconfig mailing listFontconfig at lists.freedesktop.orghttps://lists.freedesktop.org/mailman/listinfo/fontconfig
>
> _______________________________________________
> Fontconfig mailing list
> Fontconfig at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/fontconfig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fontconfig/attachments/20200205/3988e4d8/attachment.htm>


More information about the Fontconfig mailing list