From 4e62e7a44d7f8cdf7b7dc04609dc100e68701744 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Mon, 19 Jun 2023 15:36:01 +0200 Subject: [PATCH] pango: add patches --- ...Write-Check-length-of-the-font-table.patch | 69 +++++++++++++++++++ mingw-w64-pango/693.patch | 40 +++++++++++ mingw-w64-pango/694.patch | 36 ++++++++++ mingw-w64-pango/PKGBUILD | 17 ++++- 4 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 mingw-w64-pango/0001-DWrite-Check-length-of-the-font-table.patch create mode 100644 mingw-w64-pango/693.patch create mode 100644 mingw-w64-pango/694.patch diff --git a/mingw-w64-pango/0001-DWrite-Check-length-of-the-font-table.patch b/mingw-w64-pango/0001-DWrite-Check-length-of-the-font-table.patch new file mode 100644 index 0000000000..1cafeb465c --- /dev/null +++ b/mingw-w64-pango/0001-DWrite-Check-length-of-the-font-table.patch @@ -0,0 +1,69 @@ +From 6d8e0e28956840759553372fbe604ac7e93563c4 Mon Sep 17 00:00:00 2001 +From: Luca Bacci +Date: Tue, 18 Apr 2023 19:16:27 +0200 +Subject: [PATCH] DWrite: Check length of the font table + +Improved patch + +Fixes https://gitlab.com/inkscape/inkscape/-/issues/4224 +--- + pango/pangowin32-dwrite-fontmap.cpp | 24 +++++++++++++++++++----- + 1 file changed, 19 insertions(+), 5 deletions(-) + +diff --git a/pango/pangowin32-dwrite-fontmap.cpp b/pango/pangowin32-dwrite-fontmap.cpp +index 2db0972a..8aeee338 100644 +--- a/pango/pangowin32-dwrite-fontmap.cpp ++++ b/pango/pangowin32-dwrite-fontmap.cpp +@@ -499,7 +499,13 @@ pango_win32_dwrite_font_check_is_hinted (PangoWin32Font *font) + + if (dwrite_font_face != NULL) + { +- UINT32 gasp_tag = DWRITE_MAKE_OPENTYPE_TAG ('g', 'a', 's', 'p'); ++ const UINT32 gasp_tag = DWRITE_MAKE_OPENTYPE_TAG ('g', 'a', 's', 'p'); ++ /* The The 'gasp' table consists of a header (4 bytes) followed ++ * by a sequence of fixed-size entries (4 bytes each) */ ++ /* header: struct { ushort version; ushort numRanges; } */ ++ const UINT32 TABLE_HEADER_SIZE = 4; ++ /* entry: struct { ushort rangeMaxPPEM; ushort rangeGaspBehavior; } */ ++ const UINT32 TABLE_ENTRY_SIZE = 4; + UINT32 table_size; + const unsigned short *table_data; + void *table_ctx; +@@ -512,22 +518,30 @@ pango_win32_dwrite_font_check_is_hinted (PangoWin32Font *font) + &table_ctx, + &exists))) + { +- if (exists) ++ if (exists && table_size > TABLE_HEADER_SIZE) + { + guint16 version = DWRITE_NEXT_USHORT (table_data); + + if (version == 0 || version == 1) + { + guint16 num_ranges = DWRITE_NEXT_USHORT (table_data); +- guint16 i; ++ UINT32 max_ranges = (table_size - TABLE_HEADER_SIZE) / TABLE_ENTRY_SIZE; ++ guint16 i = 0; + +- for (i = 0; !result && i < num_ranges && i < (table_size / sizeof (guint16)); i ++) ++ if (num_ranges > max_ranges) ++ num_ranges = max_ranges; ++ ++ for (i = 0; i < num_ranges; i++) + { ++ G_GNUC_UNUSED + guint16 ppem = DWRITE_NEXT_USHORT (table_data); + guint16 behavior = DWRITE_NEXT_USHORT (table_data); + + if (behavior & (GASP_GRIDFIT | GASP_SYMMETRIC_GRIDFIT)) +- result = TRUE; ++ { ++ result = TRUE; ++ break; ++ } + } + } + } +-- +2.39.1.windows.1 + diff --git a/mingw-w64-pango/693.patch b/mingw-w64-pango/693.patch new file mode 100644 index 0000000000..f5a1ffda57 --- /dev/null +++ b/mingw-w64-pango/693.patch @@ -0,0 +1,40 @@ +From a31602144ff6fc05ff2a26e3c78d618896dc45e5 Mon Sep 17 00:00:00 2001 +From: Chun-wei Fan +Date: Wed, 10 May 2023 12:33:14 +0800 +Subject: [PATCH] pangocairo-win32font.c: Work around Cairo API becoming C++ + +Without adding a small C++ source file in order to include cairo-dwrite.h, +where cairo_dwrite_font_face_create_for_dwrite_fontface() now resides and have +thus become a C++ API, work around this by adding a wrapper prototype for our +own purposes so that we can continue to call that function directly from C. +--- + pango/pangocairo-win32font.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c +index 9d52dbcf3..74dfeab1e 100644 +--- a/pango/pangocairo-win32font.c ++++ b/pango/pangocairo-win32font.c +@@ -32,6 +32,19 @@ + + #include + ++#if defined (HAVE_CAIRO_WIN32_DIRECTWRITE) && \ ++ ((CAIRO_VERSION_MAJOR > 1) || \ ++ (CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR > 17) || \ ++ (CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR == 17 && CAIRO_VERSION_MICRO > 6)) ++/* ++ * We are using C here, so use a workaround as cairo-dwrite.h from 1.17.8 ++ * can only be used in C++, which replaces the C-friendly version of ++ * cairo_dwrite_font_face_create_for_dwrite_fontface() ++ */ ++extern cairo_font_face_t * ++cairo_dwrite_font_face_create_for_dwrite_fontface (void *dwrite_font_face); ++#endif ++ + #define PANGO_TYPE_CAIRO_WIN32_FONT (pango_cairo_win32_font_get_type ()) + #define PANGO_CAIRO_WIN32_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_CAIRO_WIN32_FONT, PangoCairoWin32Font)) + #define PANGO_CAIRO_WIN32_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_CAIRO_WIN32_FONT, PangoCairoWin32FontClass)) +-- +GitLab + diff --git a/mingw-w64-pango/694.patch b/mingw-w64-pango/694.patch new file mode 100644 index 0000000000..01119cb276 --- /dev/null +++ b/mingw-w64-pango/694.patch @@ -0,0 +1,36 @@ +From b4c5e9ff7e5c0b70b8a4549fc89931b58034c426 Mon Sep 17 00:00:00 2001 +From: Seungha Yang +Date: Fri, 26 May 2023 20:23:47 +0900 +Subject: [PATCH] win32: Fix 32bit build crash on DeleteDC() + +Calling convention mismatch will result in crash or so + +Fixes: https://gitlab.gnome.org/GNOME/pango/-/issues/749 +--- + pango/pangowin32.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/pango/pangowin32.c b/pango/pangowin32.c +index 7b6325a5c..4e9dc6c44 100644 +--- a/pango/pangowin32.c ++++ b/pango/pangowin32.c +@@ -126,7 +126,15 @@ _pango_win32_font_init (PangoWin32Font *win32font) + win32font->glyph_info = g_hash_table_new_full (NULL, NULL, NULL, g_free); + } + +-static GPrivate display_dc_key = G_PRIVATE_INIT ((GDestroyNotify) DeleteDC); ++static void ++_delete_dc (HDC dc) ++{ ++ /* Don't pass DeleteDC func pointer to the GDestroyNotify. ++ * 32bit build requires matching calling convention (__cdecl vs __stdcall) */ ++ DeleteDC (dc); ++} ++ ++static GPrivate display_dc_key = G_PRIVATE_INIT ((GDestroyNotify) _delete_dc); + static GPrivate dwrite_items = G_PRIVATE_INIT ((GDestroyNotify) pango_win32_dwrite_items_destroy); + + HDC +-- +GitLab + diff --git a/mingw-w64-pango/PKGBUILD b/mingw-w64-pango/PKGBUILD index 29474eb63a..5c6d57bf99 100644 --- a/mingw-w64-pango/PKGBUILD +++ b/mingw-w64-pango/PKGBUILD @@ -6,7 +6,7 @@ pkgbase=mingw-w64-${_realname} pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}" "${MINGW_PACKAGE_PREFIX}-${_realname}-docs") pkgver=1.50.14 -pkgrel=1 +pkgrel=2 pkgdesc="A library for layout and rendering of text (mingw-w64)" arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') @@ -27,12 +27,23 @@ depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-fribidi" "${MINGW_PACKAGE_PREFIX}-libthai") options=('staticlibs' 'strip' 'emptydirs') -source=("https://download.gnome.org/sources/pango/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz") -sha256sums=('1d67f205bfc318c27a29cfdfb6828568df566795df0cb51d2189cde7f2d581e8') +source=("https://download.gnome.org/sources/pango/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz" + "0001-DWrite-Check-length-of-the-font-table.patch" + "https://gitlab.gnome.org/GNOME/pango/-/merge_requests/693.patch" + "https://gitlab.gnome.org/GNOME/pango/-/merge_requests/694.patch") +sha256sums=('1d67f205bfc318c27a29cfdfb6828568df566795df0cb51d2189cde7f2d581e8' + '9a21e1aa158610975922b355faa0a89908d5ad066284a749e05dda309d6f0776' + 'bcffc93e63b12c0d168e5694531e4122ff142dfbe475708573c1150b133c8636' + '44c1233b81ecab73947836012ccaff1b1a7e73245ba05b2c1a5dd17fcdc035aa') prepare() { cd "${srcdir}/${_realname}-${pkgver}" + # https://gitlab.gnome.org/GNOME/pango/-/merge_requests/689 + patch -p1 -i "${srcdir}/0001-DWrite-Check-length-of-the-font-table.patch" + + patch -p1 -i "${srcdir}/693.patch" + patch -p1 -i "${srcdir}/694.patch" } build() {