From 35cb581b721ec12527cccc148ece7ab1dc99d041 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Wed, 25 Jun 2025 07:54:18 +0000 Subject: [PATCH] Bug 1962816 - Invert sign of delta-y when computing glyph advances for ExtTextOutW, because the GDI coordinate system is inverted. a=pascalc We used to have a sign-inversion like this in our cairo backend code: https://searchfox.org/mozilla-central/rev/0b6a214452a91745638b03d71da86ebe45e34efe/gfx/cairo/cairo/src/cairo-win32-surface.c#1892-1893 This was previously fixed (by me!) back in bug 454098, but in the process of updating cairo the change got lost as the code had moved around and so our old patch file no longer applied. (I'll see if I can get the standalone test program from that bug working again, and file the issue upstream.) Original Revision: https://phabricator.services.mozilla.com/D254737 Differential Revision: https://phabricator.services.mozilla.com/D254931 --- .../28-win32-vertical-glyph-advance-direction.patch | 13 +++++++++++++ gfx/cairo/README | 2 ++ gfx/cairo/cairo/src/win32/cairo-win32-surface.c | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gfx/cairo/28-win32-vertical-glyph-advance-direction.patch diff --git a/gfx/cairo/28-win32-vertical-glyph-advance-direction.patch b/gfx/cairo/28-win32-vertical-glyph-advance-direction.patch new file mode 100644 index 000000000000..98da3d6f0f3c --- /dev/null +++ b/gfx/cairo/28-win32-vertical-glyph-advance-direction.patch @@ -0,0 +1,13 @@ +diff --git a/gfx/cairo/cairo/src/win32/cairo-win32-surface.c b/gfx/cairo/cairo/src/win32/cairo-win32-surface.c +--- a/gfx/cairo/cairo/src/win32/cairo-win32-surface.c ++++ b/gfx/cairo/cairo/src/win32/cairo-win32-surface.c +@@ -347,7 +347,8 @@ cairo_int_status_t + 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); ++ /* Note that GDI coordinate system is inverted! */ ++ dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y); + + logical_x = next_logical_x; + logical_y = next_logical_y; diff --git a/gfx/cairo/README b/gfx/cairo/README index 4e10c983cf83..51ec6bb157fd 100644 --- a/gfx/cairo/README +++ b/gfx/cairo/README @@ -52,6 +52,8 @@ cff-font-creation.patch: make cairo_cff_font_t allocation consistent 27-windows-sdk-26100.patch: fix build bustage with Windows SDK 26100 +28-win32-vertical-glyph-advance-direction.patch: fix sign of glyph y-advance for ExtTextOut + ==== pixman patches ==== pixman-armasm.patch: add an ifdef guard around pixman-config.h include diff --git a/gfx/cairo/cairo/src/win32/cairo-win32-surface.c b/gfx/cairo/cairo/src/win32/cairo-win32-surface.c index 9cd6f55fcccd..13b319161801 100644 --- a/gfx/cairo/cairo/src/win32/cairo-win32-surface.c +++ b/gfx/cairo/cairo/src/win32/cairo-win32-surface.c @@ -347,7 +347,8 @@ _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); + /* Note that GDI coordinate system is inverted! */ + dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y); logical_x = next_logical_x; logical_y = next_logical_y;