ab-glyph icon indicating copy to clipboard operation
ab-glyph copied to clipboard

Embedding fonts at compile time

Open LoganDark opened this issue 2 years ago • 1 comments

I think there should be a proc macro or a const fn or something we can use to embed a Font directly in the binary such that error handling doesn't have to be performed at runtime (no possibility of a panic). Would be nice for embedded applications

LoganDark avatar Jan 06 '22 17:01 LoganDark

You can embed a font with include_bytes!. But, indeed, it will need to be parsed at runtime. ttf-parser doesn't provide const fn to parse fonts, though perhaps that's possible. ttf-parser already avoids allocation by parsing stuff on the fly during the various method calls anyway, so I'm not sure there would be too much benefit in avoiding the initial bit.

alexheretic avatar Jan 07 '22 16:01 alexheretic