The GDI coordinate system is inverted compared to cairo's here, so the

delta-y value needs to be negated, otherwise glyph runs with non-zero 
y-advances will shift in the wrong direction.

See mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=1962816 and
earlier https://bugzilla.mozilla.org/show_bug.cgi?id=454098 where this was
first discovered & fixed, but unfortunately was not upstreamed at that 
time.
This commit is contained in:
Emmanuele Bassi 2025-07-14 14:41:40 +00:00
commit 6ac5348308

View file

@ -263,7 +263,14 @@ _cairo_win32_surface_emit_glyphs (cairo_win32_surface_t *dst,
next_logical_y = _cairo_lround (next_user_y);
dxy_buf[j] = _cairo_lround (next_logical_x - logical_x);
dxy_buf[j+1] = _cairo_lround (next_logical_y - logical_y);
/* When delta-y values are present in dxy_buf (the ETO_PDY flag is used), these
* represent "displacement along the vertical direction of the font" (per MSDN:
* https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-exttextoutw)
* with positive values being upward (observed behavior, not explicitly documented).
* This is the opposite of the top-to-bottom logical coordinate space used here,
* so the subtraction is reversed compared to what would otherwise be expected.
*/
dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y);
logical_x = next_logical_x;
logical_y = next_logical_y;