[Xcb] Proportional fonts and text extents

Jake LeMaster ssoundasleep at gmail.com
Sun Apr 26 18:52:44 PDT 2009


I threw this together to compare extents results for whatever font you 
want to specify on a test string:

http://ircage.org/spewns/shiz/extents.c

When using the 2 proportional fonts I have in there, I get results of...

xcb extents returns a width of:  [265]
Xlib extents returns a width of: [249]

xcb extents returns a width of:  [371]
Xlib extents returns a width of: [300]

The difference can be significant, as you see. When I use the 2 
monospace fonts though, I get the results I'd expect...

xcb extents returns a width of:  [371]
Xlib extents returns a width of: [371]

xcb extents returns a width of:  [318]
Xlib extents returns a width of: [318]

Thoughts?

Thanks.

On Sun, 26 Apr 2009, Julien Danjou wrote:

> At 1240701047 time_t, Jake LeMaster wrote:
>> It seems like XCB is assuming all characters in a string are the
>> same pixel width, which will give wrong results if you use a proportional
>> font with "slim" characters like 'i', '1', '/', '(', etc.
>
> FWIW, XCB does not assume anything, it just transmit the request to the
> X server and give you the answer.
>
>> Parameter "str" is the string I want extents on, obviously, and "length"
>> woud be strlen(str). Is this how I should be going about it?
>
> Never played with that, but it seems fine.
> If you have test code with Xlib and XCB, maybe we could check if there's
> a difference between the XCB and the Xlib version requests.
>
> Cheers,
> -- 
> Julien Danjou
> // ᐰ <julien at danjou.info>   http://julien.danjou.info
> // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
> // Trust no one.
>


More information about the Xcb mailing list