3b1b/manim · error · FileNotFoundError

Can't find {font_file}.

Error message

Can't find {font_file}.

What it means

Raised by the register_font context manager (text_mobject.py:504) when the given font_file path does not exist on disk. The helper resolves the path and requires it to be present before calling manimpango.register_font, so a missing or misspelled file fails immediately.

Source

Thrown at manimlib/mobject/svg/text_mobject.py:504

           a = Text("Hello", font="Custom Font Name")
    Raises
    ------
    FileNotFoundError:
        If the font doesn't exists.
    AttributeError:
        If this method is used on macOS.
    Notes
    -----
    This method of adding font files also works with :class:`CairoText`.
    .. important ::
        This method is available for macOS for ``ManimPango>=v0.2.3``. Using this
        method with previous releases will raise an :class:`AttributeError` on macOS.
    """

    file_path = Path(font_file).resolve()
    if not file_path.exists():
        error = f"Can't find {font_file}."
        raise FileNotFoundError(error)
    try:
        assert manimpango.register_font(str(file_path))
        yield
    finally:
        manimpango.unregister_font(str(file_path))

View on GitHub (pinned to dee01804d4)

Solutions

  1. Check the path exists before use and prefer absolute paths built from __file__: Path(__file__).parent / 'fonts' / 'MyFont.ttf'
  2. Verify the filename spelling and case exactly matches the file on disk
  3. Ensure the font file is included in deployment artifacts (Dockerfile COPY, package data)

Example fix

# before
with register_font('myfont.ttf'):  # not in cwd -> raises
    Text('hi', font='My Font')

# after
from pathlib import Path
font = Path(__file__).parent / 'assets' / 'myfont.ttf'
with register_font(str(font)):
    Text('hi', font='My Font')
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
font_path = Path(font_file).resolve()
if not font_path.exists():
    raise SystemExit(f'font missing: {font_path}')
with register_font(str(font_path)):
    Text('hi', font='My Font')

Try / catch

try:
    with register_font(str(font_path)):
        render()
except FileNotFoundError:
    render_with_fallback_font()

Prevention

When it happens

Trigger: with register_font('MyFont.ttf'): Text('hi', font='My Font') where 'MyFont.ttf' is not in the current working directory; using an absolute path with a typo; the font file was not shipped/deployed with the project.

Common situations: Bundled fonts not copied into the Docker image/CI workspace; relative paths breaking when the script runs from a different directory; case-sensitivity issues on Linux for font filenames.

Related errors


AI-assisted analysis of 3b1b/manim@dee01804d4 (2026-08-14). Data as JSON: /api/errors/99604c3ae1fd6528. Report an issue: GitHub.