How are U8G2 Fonts encoded in C Files? #2580
Replies: 1 comment
-
I updated your post and added proper code tags.
Because of the wrong code tags the initial "`" had not been visible.
Each byte is represented by the corresponding ASCII glyph. If that glyph is risky, the corresponding octal escape sequence is used. Reason for using strings instead of byte arrays is parsing speed. The font file currently is almost 38MB in size. The string format above is parsed within seconds. Byte arrays would require multiple minutes (at least at the time when I decided for the string implementation) |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am trying to write a routine from scratch to parse U8G2 fonts (for educational purposes). I understand the 23 byte header and I understand in general how the run length compression works. But what I do not understand is how the fonts are encoded into the C source files. I am trying to access individual bytes of the header, but the strings in the source don't make sense. I have tried a few different ways to manipulate it, including doing a base64 decode of the string, but no luck. Example below. How do I get the string in the const below into something I can interpret and parse byte-by-byte?
The posts I have seen indicate that this string is just bytes, but if that were the case, the first value couldn't be "\0" because that would mean there are no glyphs in the font.
Thanks!
Example from u8g2_fonts.c:
Beta Was this translation helpful? Give feedback.
All reactions