Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font/freetype: Enable bitmap glyphs for non-color faces #3837

Merged
merged 4 commits into from
Dec 30, 2024

Conversation

sin-ack
Copy link
Contributor

@sin-ack sin-ack commented Dec 29, 2024

This allows for crisp bitmap font rendering once again. Tested with Terminus (TTF), and at both 1x and 2x DPI the font renders perfectly (click for 1:1 size):

Terminus (TTF), size 12, 96 DPI

Terminus (TTF), size 12, 192 DPI

@sin-ack
Copy link
Contributor Author

sin-ack commented Dec 29, 2024

@mitchellh Since you were the author of #1428, can you elaborate on what you mean by "issues with cell metrics and rasterization"?

The original version had issues converting properly and caused broken
glyphs. This version tries to be as simple as possible in order to make
it easy to understand. I haven't measured the performance but in
practice this will only happen during the first render of the glyph
after a face change (i.e. during launch or when changing font size).
This allows for crisp bitmap font rendering once again.
@sin-ack sin-ack changed the title font: Enable bitmap glyphs for non-color faces font/freetype: Enable bitmap glyphs for non-color faces Dec 29, 2024
@mitchellh mitchellh added this to the 1.0.1 milestone Dec 29, 2024
src/font/face/freetype_convert.zig Show resolved Hide resolved
//
// This must be enabled for color faces though because those are
// often colored bitmaps, which we support.
.no_bitmap = !self.face.hasColor(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting I'm going to consider the implications of this a bit further. I don't remember the full history here.

Now we can be certain that bitmap fonts stay crisp. :^)
This is an expected occurrence with bitmap glyphs and causes unnecessary
spam when using the terminal with one.
@mitchellh
Copy link
Contributor

Okay, I've been running locally with this pulled in for a couple days, and I can't remember why that original comment was there. I think it's likely that Qwer's work on metrics just resolved that for us (or some other work along the way, since that line is ancient). Merging.

@mitchellh mitchellh merged commit 2f6860f into ghostty-org:main Dec 30, 2024
20 of 21 checks passed
mitchellh added a commit that referenced this pull request Dec 30, 2024
macOS bitmap-only fonts are a poorly documented format, which are often
distributed as `.dfont` or `.dfon` files. They use a 'bhed' table in
place of the usual 'head', but the table format is byte-identical, so
enabling the use of bitmap-only fonts only requires us to properly fetch
this table while calculating metrics.

ref: https://fontforge.org/docs/techref/bitmaponlysfnt.html

Reverts #3550 for obvious reasons, and may close issue #2168 because
this should now mean that bitmap fonts are properly supported under both
font backends due to #3837 - unless `otb` fonts are still not properly
supported under FreeType (they are not supported under CoreText because
CoreText does not know how to handle them).

I tested this change with the `.dfont` distribution of
[Cozette](https://github.com/slavfox/Cozette) v1.25.2 and saw no visual
issues.
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.

2 participants