hagronnestad / nextion-font-editor

🔠📄 Extensive Nextion .zi font format documentation, file parser, font generator and simple font editor.
59 stars 18 forks source link

Change the amount of whitespace above and/or below characters #22

Open slamadeleine opened 3 years ago

slamadeleine commented 3 years ago

I have been trying to get big text at the top of a Nextion project but the font has a lot of whitespace at the top because of the size (254).

I stumbled upon this project and tried to move the chars up and save it but sadly it won't save the moving process once you press save.

I installed visual studio and opened up the source code, so far so good, but I don't know how to get that process to update the actual bitmap of the char instead of just the display.

Thinking about it, I'd like to make the chars less high (crop the top and bottom whitespace). Can you give me quick pointers on how you would do that? (I think something like reparsing every bitmap and dropping some predefined amount of white at the beginning and at the bottom would work...) I don't mind doing the leg work, I just need to be pointed in the right direction.

Thanks!

fvanroie commented 3 years ago

Hi,

OK this has been a long time since I looked at this code, so going from memory. The characters are stored in their own class as a subclass of the ziFont object. The shared properties are in the font, while the imagedata and codepoint info is stored in the character properties.

A character has both a bitmap image and a compressed binary representation. A flag stores which is the more recent updated source and there are functions to convert from binary to bitmap and vice versa.

Changing the proportions of a font and all it's characters in bulk might not be trivial. I would suggest, creating a second font with the smaller size, and then copying the character bitmaps over and adding the trimmed characters back to the new font.