From fe6ad6274aa4ba102b25c28d96e83d0b22b59387 Mon Sep 17 00:00:00 2001 From: Mohit Sharma Date: Sun, 19 Jul 2026 15:59:44 +0530 Subject: [PATCH 1/3] Fix rendering bug for small Chinese characters by adding FT_LOAD_NO_BITMAP --- src/ft2font.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ft2font.cpp b/src/ft2font.cpp index 3e53a87343a6..187e80b29942 100644 --- a/src/ft2font.cpp +++ b/src/ft2font.cpp @@ -639,7 +639,8 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph, void FT2Font::load_glyph(FT_UInt glyph_index, FT_Int32 flags) { - FT_CHECK(FT_Load_Glyph, face, glyph_index, flags); + // Yahan flags ke aage | FT_LOAD_NO_BITMAP add kar diya hai + FT_CHECK(FT_Load_Glyph, face, glyph_index, flags | FT_LOAD_NO_BITMAP); FT_Glyph thisGlyph; FT_CHECK(FT_Get_Glyph, face->glyph, &thisGlyph); glyphs.push_back(thisGlyph); From c3e1c256e74b17190760082dc23458c2a0bca26f Mon Sep 17 00:00:00 2001 From: Mohit Sharma Date: Tue, 21 Jul 2026 22:26:12 +0530 Subject: [PATCH 2/3] Clarify comment in load_glyph function Updated comment to clarify the purpose of FT_LOAD_NO_BITMAP. --- src/ft2font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ft2font.cpp b/src/ft2font.cpp index 187e80b29942..a2bcad884421 100644 --- a/src/ft2font.cpp +++ b/src/ft2font.cpp @@ -639,7 +639,7 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph, void FT2Font::load_glyph(FT_UInt glyph_index, FT_Int32 flags) { - // Yahan flags ke aage | FT_LOAD_NO_BITMAP add kar diya hai + // Force vector outlines by ignoring embedded bitmaps to fix small character rendering FT_CHECK(FT_Load_Glyph, face, glyph_index, flags | FT_LOAD_NO_BITMAP); FT_Glyph thisGlyph; FT_CHECK(FT_Get_Glyph, face->glyph, &thisGlyph); From 16067e149806bccdaf2c01d1a68c7800d67f335b Mon Sep 17 00:00:00 2001 From: Mohit Sharma Date: Tue, 21 Jul 2026 22:30:02 +0530 Subject: [PATCH 3/3] Update comment to English and add test for small character rendering --- lib/matplotlib/tests/test_text.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 83b65be400db..b43222cbb9c4 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -1317,3 +1317,8 @@ def test_draw_text_as_path_fallback(monkeypatch): _test_complex_shaping(subfig[0]) _test_text_features(subfig[1]) _test_text_language(subfig[2]) +def test_small_chinese_character_rendering(): + fig, ax = plt.subplots() + ax.text(0.5, 0.5, '字体', fontsize=6) + # Smoke test to ensure it renders without crashing + fig.canvas.draw() \ No newline at end of file