From d9085c069c5e09b8cedba2c584ac3f18d550da04 Mon Sep 17 00:00:00 2001 From: Pattems Date: Tue, 13 Oct 2026 18:11:01 -0400 Subject: [PATCH 1/3] fix: use fontconfig font registration on all non-Windows, non-macOS systems _register_font and _unregister_font were only defined when UNAME_SYSNAME is Linux, Windows or Darwin. On FreeBSD and other Unix-like systems none of the IF branches matched, so importing manimpango failed with "ImportError: cannot import name '_register_font'". Those systems use fontconfig like Linux does, so make the fontconfig branch the default for everything except Windows and macOS. --- manimpango/_register_font.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manimpango/_register_font.pyx b/manimpango/_register_font.pyx index 06d44976..3382aabf 100644 --- a/manimpango/_register_font.pyx +++ b/manimpango/_register_font.pyx @@ -44,7 +44,8 @@ cpdef bint _fc_unregister_font(set registered_fonts, str font_path): return True -IF UNAME_SYSNAME == "Linux": +# Linux, the BSDs and other Unix-like systems use fontconfig directly. +IF UNAME_SYSNAME != "Windows" and UNAME_SYSNAME != "Darwin": _register_font = _fc_register_font _unregister_font = _fc_unregister_font From 586baf40066d0f20b29ac7932f473405221bf5a4 Mon Sep 17 00:00:00 2001 From: Pattems Date: Tue, 13 Oct 2026 20:03:45 -0400 Subject: [PATCH 2/3] tests: gate the fontconfig unregister tests on the backend, not on linux test_fail_just_unregister is skipped on Linux because fontconfig's unregister_font() always returns True, and test_both_fc_and_register_font_are_same only runs on Linux. Both depend on the fontconfig backend, not on Linux itself. That backend is used on every platform except Windows and macOS. On FreeBSD, for example, the first test ran and failed, and the second never ran. Add a FONTCONFIG flag and use it in those two skip conditions. Nothing changes on Linux, Windows or macOS. --- tests/test_fonts.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_fonts.py b/tests/test_fonts.py index c6676709..b764a67c 100644 --- a/tests/test_fonts.py +++ b/tests/test_fonts.py @@ -14,6 +14,9 @@ from . import FONT_DIR from ._manim import MarkupText +# Platforms other than Windows and macOS register fonts through fontconfig. +FONTCONFIG = not sys.platform.startswith(("win32", "darwin")) + @contextmanager def register_font(font_file: Path): @@ -93,7 +96,7 @@ def test_warning(font_file, font_name): @pytest.mark.skipif( - sys.platform.startswith("linux"), reason="unsupported api for linux" + FONTCONFIG, reason="unsupported api for fontconfig" ) @pytest.mark.parametrize("font_name", font_lists_dict) @pytest.mark.skipif(sys.platform.startswith("darwin"), reason="always returns true") @@ -129,7 +132,7 @@ def test_simple_fonts_render(tmpdir): @pytest.mark.skipif( - not sys.platform.startswith("linux"), reason="unsupported api other than linux" + not FONTCONFIG, reason="unsupported api other than fontconfig" ) def test_both_fc_and_register_font_are_same(): assert ( From a8b976995a3c85e8be1eac9ea05de2d700e9d73a Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Sat, 17 Oct 2026 18:59:38 +0530 Subject: [PATCH 3/3] chore: fix lint issues --- tests/test_fonts.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_fonts.py b/tests/test_fonts.py index b764a67c..77aea078 100644 --- a/tests/test_fonts.py +++ b/tests/test_fonts.py @@ -95,9 +95,7 @@ def test_warning(font_file, font_name): assert "Pango-WARNING **" not in captured, "Looks like Pango raised a warning?" -@pytest.mark.skipif( - FONTCONFIG, reason="unsupported api for fontconfig" -) +@pytest.mark.skipif(FONTCONFIG, reason="unsupported api for fontconfig") @pytest.mark.parametrize("font_name", font_lists_dict) @pytest.mark.skipif(sys.platform.startswith("darwin"), reason="always returns true") def test_fail_just_unregister(font_name): @@ -131,9 +129,7 @@ def test_simple_fonts_render(tmpdir): assert Path(filename).exists() -@pytest.mark.skipif( - not FONTCONFIG, reason="unsupported api other than fontconfig" -) +@pytest.mark.skipif(not FONTCONFIG, reason="unsupported api other than fontconfig") def test_both_fc_and_register_font_are_same(): assert ( manimpango._register_font._fc_register_font