Skip to content

Added proportional bitmap font format support#9592

Open
endreszabo wants to merge 6 commits intopython-pillow:mainfrom
endreszabo:yaff-font-format
Open

Added proportional bitmap font format support#9592
endreszabo wants to merge 6 commits intopython-pillow:mainfrom
endreszabo:yaff-font-format

Conversation

@endreszabo
Copy link
Copy Markdown

This PR introduces support for YAFF proportional bitmap font support. Not only proportional, but YAFF is the ultimate bitmap font format that supersedes most popular formats. Unlike xkcd#927 this not a random 15th standard; this IS the standard to which all bitmap font should be converted to and used directly with Pillow. It is easily parsable for machines and human-friendly as you can edit the font files directly with your favorite text editor.

The following framebuffer has been created with Pillow, using the C64 font with manually added kerning pairs:

yaff-with-kerning

YAFF features include:

  • multiple-font container
  • Unicode with multi-codepoint sequences
  • Multi-byte character sets
  • Overlapping glyphs
  • Kerning
  • Vertical metrics
  • Greyscale fonts
  • Colour fonts

Out of these features only the kerning support has been implemented in this commit. In order to avoid introducing dependency on monobit, we wrote our YAFF format parser; with support for kerning.

Details on the YAFF format from the specs:

The yaff format has the following design aims:

  • Human-friendly. Truly human-readable and human-editable. For example, BDF and XML claim to be human-readable formats, but let's not kid ourselves. Human-friendly means plain text, flat, immediately visualised, easy on the eye, and light and obvious syntax. We should avoid duplication of information, unless it is of obvious use to a human user.
  • Able to represent fixed-width and proportional fonts.
  • Preserves comments, metadata and metrics. Formats such as BDF contain a wealth of metadata such as names, acknowledgements and style specification, but also font metrics that affect the way the font is displayed. The yaff format should preserve these.
  • Able to represent Unicode fonts as well as codepage fonts.

endreszabo and others added 2 commits April 28, 2026 14:35
Comment thread src/PIL/ImageFont.py Outdated
Comment thread src/PIL/ImageFont.py Outdated
@radarhere
Copy link
Copy Markdown
Member

Unlike xkcd#927 this not a random 15th standard; this IS the standard to which all bitmap font should be converted to and used directly with Pillow

As far as I can see, YAFF resides within monobit, which has 244 stars on GitHub, and is still in 'Beta' on PyPI.

Your claim seems a bit superlative, especially considering that https://github.com/robhagemans/monobit/blob/master/YAFF.md states

Does the world need yet another font format?
No. No, it doesn't.

I'm not saying that this shouldn't be a part of Pillow, but it would good to assess exactly how much use this feature would receive. Are there any articles you can link to demonstrating widespread acceptance?

What advantage do you see in embedding this support into Pillow directly, rather than, say, using monobit to convert a YAFF font into PCF or BDF, which Pillow already supports?

radarhere and others added 3 commits April 28, 2026 23:48
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
@endreszabo
Copy link
Copy Markdown
Author

endreszabo commented Apr 28, 2026

As far as I can see, YAFF resides within monobit, which has 244 stars on GitHub, and is still in 'Beta' on PyPI.

Your claim seems a bit superlative, especially considering that https://github.com/robhagemans/monobit/blob/master/YAFF.md states

Does the world need yet another font format?
No. No, it doesn't.

Yes, I am very enthusiastic as I spent years with Jimp + AngelCode BMFont to achieve the same (= my goal is to render a proportional bitmap font with kerning). And even with that, BMFont is basically PNG sprites, so you can't 'detach' the font rendering from the sprite images (no fill= for instance, you need to have a unique set of PNG files for each font color you'd need).

I'm not saying that this shouldn't be a part of Pillow, but it would good to assess exactly how much use this feature would receive. Are there any articles you can link to demonstrating widespread acceptance?

I have no evidence for widespread acceptance. This PR will certainly raise awareness of its existence.

What advantage do you see in embedding this support into Pillow directly, rather than, say, using monobit to convert a YAFF font into PCF or BDF, which Pillow already supports?

Immediate benefit is the proportional (variable width) glyph support (+kerning, which narrows the scope even further in the field of bitmap fonts) that BDF and PCF do not have.

@radarhere
Copy link
Copy Markdown
Member

Did you use AI to develop this?

@endreszabo
Copy link
Copy Markdown
Author

Did you use AI to develop this?

Yes, I was using Opus.

@radarhere radarhere added the 🤖-assisted AI-assisted label Apr 28, 2026
Comment thread src/PIL/YaffFontFile.py Outdated
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants