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 diff --git a/tests/test_fonts.py b/tests/test_fonts.py index c6676709..77aea078 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): @@ -92,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( - sys.platform.startswith("linux"), reason="unsupported api for linux" -) +@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): @@ -128,9 +129,7 @@ def test_simple_fonts_render(tmpdir): assert Path(filename).exists() -@pytest.mark.skipif( - not sys.platform.startswith("linux"), reason="unsupported api other than linux" -) +@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