[DEVEL] XftTextExtents8 function and spaces characters

Lucien Gentis lucien.gentis at univ-lorraine.fr
Wed Apr 24 09:16:17 UTC 2019


Hi,

Thanks for your answer.

As I have to know exact width of the string, I found that solution :

For every font I use, I calculate the width of a space.

And every time I use XftTextExtents8, I test if the last character of 
the string is a space or not.

If it's a space, I add the width of the space to the width of the string.

Cheers,

Lucien

Le 24/04/2019 à 09:19, walter harms a écrit :
> Hi,
> i did not see an answer so i will try:
>
> The docu says: "XftTextExtents8 computes the pixel extents of "string" when drawn with "font". "
> IMHO:
> the point here is: "pixel extents" i read "find the last pixel"
> white space has no pixel so it should be ignored.
> In that logic leading spaces get not ignored because they cause an offset.
>
> You expected "string width" what is obviously not the same-
>
> re,
>   wh
>
> Am 13.04.2019 16:21, schrieb Lucien Gentis:
>> Hello,
>>
>> I use  XftTextExtents8 (display,font,(FcChar8
>> *)str,strlen(str),&glyphInfo); instruction to compute width of string str
>>
>> Here are values of glyphInfo.width with following strings:
>>
>> String                glyphInfo.width
>> -------------------------------------
>> "e"                    9
>> " e" (leading space)   13
>> "e " (trailing space)  9
>> "e e"                  22
>>
>> So it seems thattrailing spaces are not taken into account to compute
>> string width.
>>
>> is it a bug ?
>>
>>
>>
>>
>> _______________________________________________
>> xorg at lists.x.org: X.Org support
>> Archives: http://lists.freedesktop.org/archives/xorg
>> Info: https://lists.x.org/mailman/listinfo/xorg
>> Your subscription address: %(user_address)s
> _______________________________________________
> xorg at lists.x.org: X.Org support
> Archives: http://lists.freedesktop.org/archives/xorg
> Info: https://lists.x.org/mailman/listinfo/xorg
> Your subscription address: %(user_address)s


More information about the xorg mailing list