[Xcb] xcb_image_text_8 Transparent Background

Peter Harris pharris at opentext.com
Tue Jan 4 14:49:48 PST 2011


On 2011-01-02 04:05, Cinolt wrote:
> After trying to use xcb_poly_text_8, I seem to be facing a similar
> problem as is described here:
> http://lists.freedesktop.org/archives/xcb/2007-January/002533.html
> 
> I define a structure:
> 
> struct
>   {
>     char *chars;
>     int nchars;
>     int delta;
>     xcb_font_t font;
>   } item;

This has to go on the wire, so pointers and unsized types like "int" are
definitely wrong.

It should be something like (untested):
struct {
	uint8_t nchars;
	int8_t  delta;
	char	text[];
} item;

Allocating an item of the correct size is left as an exercise for the
reader (although I believe C99 makes this easy).

Nobody uses the font switch option, because it's usually easier to just
ChangeGC in between PolyText requests than to build up a compound
PolyText request.

> cookie_text = xcb_poly_text_8_checked(c, w, gc, 16, 16, 1, (const
> uint8_t*)&item);

Should be (2 + item.nchars), not 1. It's a total length of the buffer
you've passed in.

Or 2*nitems + summation(item[i].nchars) if you pass in an array of
items. Note that all of the items must be contiguous in memory.

> and get the output 16, which in X11/X.h is defined as BadLength. Are
> there any examples at all of a working implementation of this function?

Most people use Pango or similar in combination with the RENDER
extension in order to get anti-aliased fonts and better unicode support.
Core X font rendering does not support anti-aliasing (and, though it
supports almost any glyph set, predates unicode).

Peter Harris
-- 
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866


More information about the Xcb mailing list