{"record":{"id":"99604c3ae1fd6528","repo":"3b1b/manim","slug":"can-t-find-font-file","errorCode":null,"errorMessage":"Can't find {font_file}.","messagePattern":"Can't find (.+?)\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"manimlib/mobject/svg/text_mobject.py","lineNumber":504,"sourceCode":"           a = Text(\"Hello\", font=\"Custom Font Name\")\n    Raises\n    ------\n    FileNotFoundError:\n        If the font doesn't exists.\n    AttributeError:\n        If this method is used on macOS.\n    Notes\n    -----\n    This method of adding font files also works with :class:`CairoText`.\n    .. important ::\n        This method is available for macOS for ``ManimPango>=v0.2.3``. Using this\n        method with previous releases will raise an :class:`AttributeError` on macOS.\n    \"\"\"\n\n    file_path = Path(font_file).resolve()\n    if not file_path.exists():\n        error = f\"Can't find {font_file}.\"\n        raise FileNotFoundError(error)\n    try:\n        assert manimpango.register_font(str(file_path))\n        yield\n    finally:\n        manimpango.unregister_font(str(file_path))\n","sourceCodeStart":486,"sourceCodeEnd":510,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/mobject/svg/text_mobject.py#L486-L510","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the path exists before use and prefer absolute paths built from __file__: Path(__file__).parent / 'fonts' / 'MyFont.ttf'","Verify the filename spelling and case exactly matches the file on disk","Ensure the font file is included in deployment artifacts (Dockerfile COPY, package data)"],"exampleFix":"# before\nwith register_font('myfont.ttf'):  # not in cwd -> raises\n    Text('hi', font='My Font')\n\n# after\nfrom pathlib import Path\nfont = Path(__file__).parent / 'assets' / 'myfont.ttf'\nwith register_font(str(font)):\n    Text('hi', font='My Font')","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfont_path = Path(font_file).resolve()\nif not font_path.exists():\n    raise SystemExit(f'font missing: {font_path}')\nwith register_font(str(font_path)):\n    Text('hi', font='My Font')","typeGuard":null,"tryCatchPattern":"try:\n    with register_font(str(font_path)):\n        render()\nexcept FileNotFoundError:\n    render_with_fallback_font()","preventionTips":["Resolve font paths relative to your script via Path(__file__).parent","Ship fonts with the project and verify presence in CI/deploy steps","Match filename case exactly on case-sensitive filesystems"],"tags":["manim","font","file-not-found","text","environment"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}