From 7b322cec56252ef4ef563fe53da6bacccbbae124 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 30 Jul 2026 03:01:24 -0400 Subject: [PATCH 1/2] Re-enable tests when building wasm wheels --- .github/workflows/wasm.yml | 1 - pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 48e4e35a56ef..f263560c80b5 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -53,7 +53,6 @@ jobs: uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0 env: CIBW_PLATFORM: "pyodide" - CIBW_TEST_COMMAND: "true" - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: diff --git a/pyproject.toml b/pyproject.toml index d1999d10acc8..cd10d5afd4c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -461,7 +461,7 @@ test-command = [ """\ pytest -p no:cacheprovider --pyargs \ matplotlib mpl_toolkits.axes_grid1 mpl_toolkits.axisartist mpl_toolkits.mplot3d \ - -k 'not test_complex_shaping'""", + """, ] [tool.cibuildwheel.pyodide.environment] # Exception handling is needed for pybind11: From b7f43dfe4efe20c8c4e62db30ec8c0737f569f68 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 1 Aug 2026 02:22:43 -0400 Subject: [PATCH 2/2] Add more debug logging --- lib/matplotlib/backends/backend_agg.py | 13 +++++++ pyproject.toml | 12 ++++--- subprojects/freetype2.wrap | 4 ++- ...g-dlg-logging-library-to-meson-build.patch | 28 +++++++++++++++ ...Fix-debug-logging-when-NDEBUG-is-set.patch | 36 +++++++++++++++++++ .../0005-Enable-debug-logging.patch | 26 ++++++++++++++ 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 subprojects/packagefiles/0003-Add-missing-dlg-logging-library-to-meson-build.patch create mode 100644 subprojects/packagefiles/0004-Fix-debug-logging-when-NDEBUG-is-set.patch create mode 100644 subprojects/packagefiles/0005-Enable-debug-logging.patch diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index 6fe5eca0d070..0feaf0c98f6d 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -178,7 +178,16 @@ def _draw_text_glyphs_and_boxes(self, gc, x, y, angle, glyphs, boxes): sin = math.sin(math.radians(angle)) load_flags = get_hinting_flag() for font, size, glyph_index, slant, extend, dx, dy in glyphs: # dy is upwards. + print(f'Rendering {font.fname}@{size}/{self.dpi}:', + glyph_index, slant, extend, dx, dy) font.set_size(size, self.dpi) + print( + f'set_transform {sin=} {cos=}', + (0x10000 * np.array([[cos, -sin], [sin, cos]]) + @ [[extend, extend * slant], [0, 1]]).round().astype(int), + [round(0x40 * (x + dx * cos - dy * sin)), + # FreeType's y is upwards. + round(0x40 * (self.height - y + dx * sin + dy * cos))]) font._set_transform( (0x10000 * np.array([[cos, -sin], [sin, cos]]) @ [[extend, extend * slant], [0, 1]]).round().astype(int), @@ -193,6 +202,9 @@ def _draw_text_glyphs_and_boxes(self, gc, x, y, angle, glyphs, boxes): if not gc.get_antialiased(): buffer *= 0xff # draw_text_image's y is downwards & the bitmap bottom side. + print(f'draw_text_image at {bitmap.left=} {self.height=} {bitmap.top=} ' + f'{buffer.shape[0]=} {int(self.height)=} ' + f'{int(self.height) - bitmap.top + buffer.shape[0]=}') self._renderer.draw_text_image( buffer, bitmap.left, int(self.height) - bitmap.top + buffer.shape[0], @@ -205,6 +217,7 @@ def _draw_text_glyphs_and_boxes(self, gc, x, y, angle, glyphs, boxes): gc1.set_linewidth(0) gc1.set_snap(gc.get_snap()) for dx, dy, w, h in boxes: # dy is upwards. + print(f'Draw rect {dx=} {dy=} {w=} {h=}') if gc1.get_snap() in [None, True]: # Prevent thin bars from disappearing by growing symmetrically. if w < 1: diff --git a/pyproject.toml b/pyproject.toml index cd10d5afd4c7..af2e4387a156 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -461,16 +461,20 @@ test-command = [ """\ pytest -p no:cacheprovider --pyargs \ matplotlib mpl_toolkits.axes_grid1 mpl_toolkits.axisartist mpl_toolkits.mplot3d \ - """, + -k 'test_mathtext or last_resort' || true""", + "cp -a result_images {project}", ] +test-environment = { FT2_DEBUG="any:7 -v" } +[tool.cibuildwheel.pyodide.config-settings] +setup-args = ["-Dbuildtype=debug"] [tool.cibuildwheel.pyodide.environment] # Exception handling is needed for pybind11: # https://github.com/pybind/pybind11/pull/5298 # And the pyemscripten_2025_0 platform and above uses -fwasm-exceptions for this. # https://pyodide.org/en/stable/development/abi/313.html -CFLAGS = "-fwasm-exceptions" -CXXFLAGS = "-fwasm-exceptions" -LDFLAGS = "-fwasm-exceptions" +CFLAGS = "-fwasm-exceptions -g" +CXXFLAGS = "-fwasm-exceptions -g" +LDFLAGS = "-fwasm-exceptions -g" [tool.cibuildwheel.windows] before-build = [ diff --git a/subprojects/freetype2.wrap b/subprojects/freetype2.wrap index 28b452035cf0..2aa7b8f68b1d 100644 --- a/subprojects/freetype2.wrap +++ b/subprojects/freetype2.wrap @@ -10,7 +10,9 @@ source_hash = 36bc4f1cc413335368ee656c42afca65c5a3987e8768cc28cf11ba775e785a5f # First patch allows using our bundled HarfBuzz. # Second patch fixes symbol problems on wasm. -diff_files = freetype-2.14.1-static-harfbuzz.patch, freetype-2.14.1-wasm-visibility.patch +# Third and fourth fix debug logging https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/438 +# Fifth enables debug logging. +diff_files = freetype-2.14.1-static-harfbuzz.patch, freetype-2.14.1-wasm-visibility.patch, 0003-Add-missing-dlg-logging-library-to-meson-build.patch, 0004-Fix-debug-logging-when-NDEBUG-is-set.patch, 0005-Enable-debug-logging.patch [provide] freetype2 = freetype_dep diff --git a/subprojects/packagefiles/0003-Add-missing-dlg-logging-library-to-meson-build.patch b/subprojects/packagefiles/0003-Add-missing-dlg-logging-library-to-meson-build.patch new file mode 100644 index 000000000000..2832008e83ef --- /dev/null +++ b/subprojects/packagefiles/0003-Add-missing-dlg-logging-library-to-meson-build.patch @@ -0,0 +1,28 @@ +From a4279b16570434a2d46f073d221a1d3a5034f9e7 Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Fri, 31 Jul 2026 23:09:34 -0400 +Subject: [PATCH 3/5] Add missing dlg logging library to meson build + +Without this source file, the final library fails to link if you set +`FT_DEBUG_LOGGING` for the build. + +Signed-off-by: Elliott Sales de Andrade +--- + meson.build | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/meson.build b/meson.build +index 046163ecd..c731ed938 100644 +--- a/meson.build ++++ b/meson.build +@@ -236,6 +236,7 @@ endif + # might make these platform-specific files much smaller, and could be moved + # into `ftsystem.c` as well. + ++ft2_sources += 'src/dlg/dlgwrap.c' + if host_machine.system() == 'windows' + winmod = import('windows') + ft2_sources += [ +-- +2.55.0 + diff --git a/subprojects/packagefiles/0004-Fix-debug-logging-when-NDEBUG-is-set.patch b/subprojects/packagefiles/0004-Fix-debug-logging-when-NDEBUG-is-set.patch new file mode 100644 index 000000000000..5d97678d9716 --- /dev/null +++ b/subprojects/packagefiles/0004-Fix-debug-logging-when-NDEBUG-is-set.patch @@ -0,0 +1,36 @@ +From 36633fe4a2bc417ce575f6aa74e9f3a6da20b7e7 Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Fri, 31 Jul 2026 23:12:47 -0400 +Subject: [PATCH 4/5] Fix debug logging when `NDEBUG` is set + +In Meson, the default for `b_ndebug` is `is-release`, which will enable +it when in release mode. Additionally, in `dlg`, the default log level +is `warn` if `NDEBUG` is set or `trace` otherwise. Because `FT_LOG` uses +the `trace` level always, all debug logging will be disabled if +`b_ndebug` is set (or in release mode). + +Using `NDEBUG` is not documented anywhere to toggle debug logging, so +define `DLG_LOG_LEVEL` so that `trace` level is always output by `dlg`. +FreeType's other (runtime or otherwise) configuration remains as it is +to toggle logging per-component. + +Signed-off-by: Elliott Sales de Andrade +--- + include/freetype/internal/ftdebug.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h +index 62b9ec2f7..f2339aff4 100644 +--- a/include/freetype/internal/ftdebug.h ++++ b/include/freetype/internal/ftdebug.h +@@ -33,6 +33,7 @@ + + #ifdef FT_DEBUG_LOGGING + #define DLG_STATIC ++#define DLG_LOG_LEVEL dlg_level_trace + #include + #include + +-- +2.55.0 + diff --git a/subprojects/packagefiles/0005-Enable-debug-logging.patch b/subprojects/packagefiles/0005-Enable-debug-logging.patch new file mode 100644 index 000000000000..00c6cfcbfba8 --- /dev/null +++ b/subprojects/packagefiles/0005-Enable-debug-logging.patch @@ -0,0 +1,26 @@ +From dc723711549e7710e074b210f48391c6b07c013e Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Sat, 1 Aug 2026 01:46:51 -0400 +Subject: [PATCH 5/5] Enable debug logging + +Signed-off-by: Elliott Sales de Andrade +--- + include/freetype/config/ftoption.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h +index b857e0ebb..bef9e6853 100644 +--- a/include/freetype/config/ftoption.h ++++ b/include/freetype/config/ftoption.h +@@ -473,7 +473,7 @@ FT_BEGIN_HEADER + * + * This option needs a C99 compiler. + */ +-/* #define FT_DEBUG_LOGGING */ ++#define FT_DEBUG_LOGGING + + + /************************************************************************** +-- +2.55.0 +