Precision xcb_render_composite_glyphs_8/16/32
Uli Schlachter
psychon at znc.in
Tue Jun 17 17:01:57 UTC 2025
Hi,
Am 13.06.25 um 05:18 schrieb Max McDougle:
> Could you please provide an explanation as to what glyphcmds is supposed to
> be?
Well, not really helpful, but: A list of glyph commands. As [1] puts it:
> glyphcmds: LISTofGLYPHITEM8 CompositeGlyphs8
> glyphcmds: LISTofGLYPHITEM16 CompositeGlyphs16
> glyphcmds: LISTofGLYPHITEM32 CompositeGlyphs32
and later:
> GLYPHITEM8 GLYPHELT8 or GLYPHABLE
> GLYPHELT16 [
> dx, dy: INT16
> glyphs: LISTofCARD16
> ]
Perhaps a bit more helpful is an example. Here is some piece of code in
cairo [2].
I will look at xcb_render_composite_glyphs_8. The first piece of data is
a structure that cairo calls x_glyph_elt_t [3] and thathas a length
field, some padding, and some delta. The delta is applied to the current
point (whatever that is initially...) and then there come [len] glyphs.
Each glyph is a uint8_t containing the glyph index. Afterwards, suitable
padding is inserted and then a new x_glyph_elt_t follows.
Does that make a tiny bit of sense?
[1]: https://www.x.org/releases/current/doc/renderproto/renderproto.txt
[2]:
https://gitlab.freedesktop.org/cairo/cairo/-/blob/3ffb6d5c07087676fabf7bd4b75c1ed9eb7e624d/src/cairo-xcb-surface-render.c?page=5#L4610
[3]:
https://gitlab.freedesktop.org/cairo/cairo/-/blob/3ffb6d5c07087676fabf7bd4b75c1ed9eb7e624d/src/cairo-xcb-surface-render.c?page=5#L4078
Perhaps a tiny example helps?
Let's suppose we have glyphs 0, 1, and 2. Each glyph has an y offset of
0 and an x offset of 10. We want to draw a run of five glyphs with this
natural offset, then a gap of 5 and then some more glyphs.
The data argument would begin with a x_glyph_elt_t with len=5. Dunno
what the deltas should be here, perhaps the position of the first glyph?
Afterwards comes five bytes of data, each one being one glyph index.
Then comes another x_glyph_elt_t describing the second run of glyphs and
having a deltax=5.
In (pseudo) code:
size_t size_of_glyph_elt_t = 8;
uint8_t first_run[5] = {0, 0, 1, 1, 2};
uint8_t second_run[2] = {2, 1};
uint8_t buffer[size_of_glyph_elt_t*2 + sizeof(first_run) +
sizeof(second_run)];
size_t position = 0;
x_glyph_elt_t* elt = &buffer[position];
elt->len = sizeof(first_run);
elt->deltax = dunno;
elt->deltay = dunno;
position += size_of_glyph_elt_t;
memcpy(&buffer[position], first_run, sizeof(first_run));
position += sizeof(first_run);
elt = &buffer[position];
elt->len = sizeof(second_run);
elt->deltax = 5;
elt->deltay = 0;
position += size_of_glyph_elt_t;
memcpy(&buffer[position], second_run, sizeof(second_run));
position += sizeof(second_run);
I hope this helps a bit.
Cheers,
Uli
--
A normal person is just someone you don't know well enough yet.
- Nettie Wiebe
More information about the Xcb
mailing list