ImageFont.truetype loads Mongolian Baiti but getbbox raises OSError: invalid reference

Open
#10,553 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by reproducing the failure with the supplied Mongolian Baiti font and ImageFont.truetype(...).getbbox("Hello") using both BASIC and RAQM layout engines. Then trace the FreeType measurement call that raises OSError: invalid reference; the issue does not name a source file or test. Done means text measurement and rendering work for this font, or the failure reports a more specific reason.

Written by the indexing model from the issue text.

Description

Awaiting OP Action Fonts

Description:

I'm encountering an issue with the Mongolian Baiti TrueType font (monbaiti.ttf) distributed with Windows.

Pillow successfully loads the font and retrieves its family name, but attempting to measure even basic Latin text raises OSError: invalid reference.

The font renders correctly in a Chromium-based application on Windows.

Environment:

Pillow: 12.3.0

Font: Mongolian Baiti Regular (monbaiti.ttf)

Layout engines tested: BASIC and RAQM

Minimal reproduction:

from PIL import ImageFont

font = ImageFont.truetype("monbaiti.ttf", 32)
print(font.getname())       # Works
print(font.getbbox("Hello"))  # OSError: invalid reference

Expected behavior:

Pillow should measure and render the text successfully, or provide a more specific error explaining why the font cannot be rendered.

Actual behavior:

OSError: invalid reference is raised during the underlying FreeType measurement operation.

Additional information:

The failure occurs with both BASIC and RAQM layout engines. The font is readable, and it renders successfully through the browser's font-rendering system.

The font file used for this was taken from the windows font directory.

Dominant language
Python
Stars
14k
Forks
2.6k
Avg merge
1d 1h
Merged PRs (30d)
205

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-pillow/Pillow

All issues in python-pillow/Pillow

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.