blit-fonts
blit-fonts copied to clipboard
Individual descender values in 32bit glyphs
Hi @azmr,
thanks for these nice fonts! I am going to use them for my experiments with https://getchip.com/pages/chip.
There is one thing I do not get, though (I am rendering these manually in Python, not using your C libs). I understand that two top-level bits (in the 32bit font) are used to specify individual extra descendants. But:
Glyph g, value 0x4e87252e, 01001110100001110010010100101110 in binary => 1 extra descendant
Glyph j, value 0x8c421004, 10001100010000100001000000000100 in binary => 2 extra descendants
Your sample image shows these descendant offsets switched, i.e. g moved down by 2 and j moved down by 1. What am I doing wrong?
Hi @ondras,
Sorry for the long delay in responding - the notification ended up in a folder in my inbox that I don't check (fixed now).
Thanks for checking them out - I'm glad if they're useful to somebody! (How did you come across this btw?)
Hmm, very odd... good catch. You're right that they're incorrectly switched. I think that was because I was originally processing those backwards and must have missed something when converting over... I'll have work out where in the chain that's going wrong and fix it.
How are the experiments going a few weeks on?
Sorry for the long delay in responding - the notification ended up in a folder in my inbox that I don't check (fixed now).
Thanks for getting to me!
(How did you come across this btw?)
I bought a cheap chinese 320x240 LED display with SPI interface to play with. Drawing individual pixels is okay-ish (speed-wise), rendering true fonts would be a serious overkill. So I googled for something truly lightweight and found your code.
How are the experiments going a few weeks on?
I decided to ignore the issue so far. It is not that serious, my 32bit fonts are just incorrectly vertically aligned. Not a big deal :)
Oh brilliant, perfect use case!
For a quick fix, you can go through the (lowercase) glyphs and just change 0x4______ to 0x8___ and vice versa. I think there's an 0x7_____ as well, which should change to 0xb____. This is adding/subtracting 4 to the high 4 bits to move the on bit up/down one.
EDIT: or... if you're parsing it manually, you can use ((glyph >> 31) & 1) + 2 * ((glyph >> 30) & 1) to compute the y offset. (I think I got that the right way round...)
I'm no longer on the dev setup from when I made this, so I'll have to get it working with my current system... but I will fix it! :)
For a quick fix, you can go through the (lowercase) glyphs and just change 0x4______ to 0x8___ and vice versa.
Right, or I can simply modify the drawing algorithm for 32bit fonts to reverse the offset value. I am drawing these myself, not using your code. I only included your glyph definition arrays into my Python code :)