-
Notifications
You must be signed in to change notification settings - Fork 71
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
Support for bitmap fonts, EBDT + EBLC tables #121
Conversation
…and EBLC tables, fixing some issues with CBLC lookup
Hi! Thanks for the patch. There are a couple of reasons why EBDT+EBLC haven't been implemented yet.
Also, what about EBSC? As for the bugs - thanks. I don't actually use those tables yet, so no guarantees. The current implementations is good enough for shaping. |
To provide some context and answer your initial questions. I'm working on a game with a custom engine. I already implemented TrueType rasterization using your library, but I would also like to support bitmap fonts since they're relatively easy to make and appear "crisper" at lower resolutions. I've been browsing around for bitmap fonts, and it seems that OTB is a fairly common format to find them in, and is commonly supported for tools that export bitmap fonts. All the ones I've found use EBDT+EBLC. I haven't seen any CBDT, CBLC or EBSC tables. For your second point, I don't think Anyway, I wanted to thank you for this awesome library! It's been working great for me so far. |
I see. Thanks for the explanation. To my understanding, the current implementation of EBDT+EBLC is identical to bdat+bloc. EBDT+EBLC added only formats 8 and 9, which we do not support anyway and which should be documented/mentioned somewhere. Including in the readme (it should be As for the code, I would suggest adding:
We already do the same trick with And in the PS: if you would have performance issues parsing those tables, we could pre-parse them more. Currently we're re-parsing a lot of data for each glyph. |
Also update the c-api crate. If this is hard, we can ignore it for now and I will update it myself after the merge. |
Addressed the follow-up comments. From the bdat specs, it doesn't allow formats 8 and 9, but it does allow format 4, so I marked that as unimplemented in the readme. I also marked 8 and 9 as unimplemented for CBDT because any format that is valid for EBDT is technically allowed to appear in CBDT. I updated the C API but admittedly I didn't really know what I was doing and was just following patterns. You might need to adjust things. |
Thanks. Looks good to me. |
Thanks for you work! I will publish a new version soon. |
Published a new version. |
This PR makes a few changes that allow
ttf_parser
to be used with bitmap fonts (i.e..otb
files):RasterImageFormat
with the various uncompressed bitmap formats that may appear in a fontThe PR also fixes some issues with CBLC parsing I found during testing:
ppem_x
and the start of the next subtable, not 4. Also, these final bytes always have to be skipped, not just when!(start_glyph_id..=end_glyph_id).contains(&glyph_id)
.location.metrics
was never populated and always held the default valueI tested the changes on Terminus fonts and on some fonts I exported using Bits'N'Picas. The Terminus fonts are monochrome with several subtables for different scales. The Bits'N'Picas fonts are 8-bit grayscale.
The PR includes an automated test using one limited example font I created myself (so there are no copyright issues).