tchapi / Adafruit-GFX-Font-Customiser

A little utility to customise pixel fonts for the Adafruit GFX library
https://tchapi.github.io/Adafruit-GFX-Font-Customiser/
MIT License
90 stars 47 forks source link

Import XOR packed #40

Open eltomjan opened 6 months ago

eltomjan commented 6 months ago

Made import preview, with optional UnXor - nice to see under the hood sometimes :-) And there are 2 old fonts from ArduinoSimulator project in test folder.

Got lof of problems trying to add export - quite random bugs in the middle of some chars. At the moment have only C# compression recovered from unfinished version (created 7 years ago...). There is a special logic - GFXglyph / bitmapOffset holds bit size of char or compressed data now. In case compression fail (size increase) there is full size and original bitmap is used

There were multiple compression versions like row bitmap array and column data bitmap and some others forgotten, but suppose bit 1 prefix was best version as it was latest I used in my old project.

https://github.com/tchapi/Adafruit-GFX-Font-Customiser/issues/39

Let me know if you prefer JS compression implementation or if C# (/cmd project) will be enough.

Here temporary C# packer version https://github.com/eltomjan/ETEhomeTools/tree/master/CSharp/GFXpack

eltomjan commented 6 months ago

Done !!! It was not so complicated to translate C# back to JS.

Not sure if design fits nice and do not like useless jQuery - trying live without :-)

Just in case short description of current format: Bitmaps is now single packed bit array.

Glyphs offset now points to bit (almost)

Compressor is almost 1:1 picked from latest C# version, btw there is also small optimisation - to speedup check of non-/zero blocks - array holding sum of 1-s and I can compare 2 sum indexes instead of iterate all bits again and again. And I need to update glyphs, so they are not text anymore (could be optional, but is it worth ??). And there is size as line comment next to Bitmaps declaration to know if compression has any sense :-)

tchapi commented 5 months ago

Sorry @eltomjan for not coming back to you early on this โ€”ย it's complicated to find personal time to contribute these days.

๐Ÿ’ช๐Ÿผ Thanks for the hard work on that.

๐Ÿ‘‰๐Ÿผ What I would still need from you if you don't mind:

Thank you!

eltomjan commented 5 months ago

Made also a demo in meantime here eltomjan.github.io ... Adafruit-GFX-Font-Customiser.htm.

I respect your preferences - this great repo is your...

In short my usecase was out of FLASH (32kB), but client wanted better UI, big fonts and extend logic... I found a way to pack these big fonts to aprox. 50% and was able to continue without problems... Also made faster print for my Adafruit_ILI9340 LCD - it was possible to sent bitmap instead of X,Y + point color each time (inspired by fillRect method). My old LinkedIn post contains most informations on one place. First link shows commit https://github.com/eltomjan/Adafruit-GFX-Library/commit/8e89c8f7192095b2554ea526317efd894c7c0af6 with Adafruit_GFX.cpp changes, visual and xor demos, etc.

eltomjan commented 5 months ago

Finished test in Wokwi simulator (FreeSerifBoldItalic9pt7b) https://wokwi.com/projects/394882822504014849

XorPack changes commit (change from default GFX to XorPacked font on ILI9341) - changed files are in project folder(s)

eltomjan commented 5 months ago

In case you do not have time, just give me instructions how to update PR and I can do that. I do not like jQuery as it does not bring much new to JS except renaming and useless mangling existing JS/DOM methods. Also had to live with jQ in DELMIA Apriso, but there it was real pain - lot of mixed parts, hard to be sure which one can appear, often no way to address them - most were named same / almost same and if you have jQ here, these unpredictable/repeated parts did unexpected things often - in JS/DOM you know what are you working with, but in jQ any event, etc. may be auto attached or refer to anything similar. Also when code is not structured much, you have element, have to think how it can be refered and then search whole "universe" (neverending file-s) for handler - it was good idea to split UI and logic, but also context often get hidden/lost in real world. And something used exceptions for normal run - jQ(?) - that is code smell - exceptions lost there exceptionality ??