Skip to content

Py313 fontconfig non linux - #133

Merged
naveen521kk merged 3 commits into
ManimCommunity:v0from
pattems:py313-fontconfig-non-linux
Oct 17, 2026
Merged

naveen521kk merged 3 commits into
ManimCommunity:v0from
pattems:py313-fontconfig-non-linux

Conversation

@pattems

@pattems pattems commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

fix: use fontconfig font registration on all non-Windows, non-macOS systems

manimpango/_register_font.pyx defines _register_font / _unregister_font under Cython compile-time IF UNAME_SYSNAME == ... branches for Linux, Windows and Darwin only. When building on FreeBSD (and NetBSD, OpenBSD, illumos, ...) none of the branches match, the names are never defined, and import manimpango fails:

ImportError: cannot import name '_register_font' from 'manimpango._register_font'

These systems use fontconfig exactly like Linux, so this makes the fontconfig branch apply to everything except Windows and macOS. Linux, Windows and macOS builds are unchanged. A second, test-only commit gates the two fontconfig-specific unregister tests on the backend rather than on linux.

Testing

Cython 3.0.12 (the <3.1 pin from pyproject.toml), Python 3.13: cythonized _register_font.pyx with compile_time_env={"UNAME_SYSNAME": ...} and listed the module-level names bound in the generated C:

UNAME_SYSNAME before after
Linux _register_font, _unregister_font set same
Windows, Darwin _register_font, _unregister_font set same
FreeBSD, NetBSD only _fc_register_font/_fc_unregister_font _register_font, _unregister_font set

Full build of main on FreeBSD 15.1, Python 3.12, 3.13 and 3.14 (pip install from the checkout, pango/cairo/fontconfig from packages):

  • before: manimpango.register_font(...) fails with the ImportError above
  • after: register_font(DejaVuSans.ttf) returns True and list_fonts() finds it

The second commit is test-only. 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 runs only on Linux. Both depend on the fontconfig backend rather than on Linux. On FreeBSD the first test ran and failed (3 cases), and the second never ran. The commit adds a FONTCONFIG flag (neither win32 nor darwin) and uses it in those two skip conditions only. Skips are unchanged on Linux, Windows and macOS.

With both commits (in-place build) on FreeBSD 15.1, pytest -q tests -k font gives 19 passed, 3 skipped (test_fail_just_unregister), 0 failed on Python 3.12, 3.13 and 3.14.

Context

Found while testing packages against Python 3.13 for FreeBSD ports (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292105).

…ystems

_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.
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.

@PhilippImhof PhilippImhof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@naveen521kk naveen521kk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! I'll do a patch release with these changes later this week.

@naveen521kk
naveen521kk merged commit 4bbf777 into ManimCommunity:v0 Oct 17, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants