AaronLiddiment / LEDText

FastLED Flexible Text Message Class requires LEDMatrix Class
89 stars 32 forks source link

Fonts bigger than ComicSansP24.h, applying multiplier? #29

Closed marcmerlin closed 2 years ago

marcmerlin commented 2 years ago

With adafruit fonts (which of course offer a lot less than LEDText), I can however use a settextsize(4) to make the font 4 times bigger. Is that possible at all with LEDText? I didn't see that in the documentation.

I have ComicSansP24.h, but my display is 160 pixels high (no, I don't have that many neopixels, I hacked LEDMatrix to work on any 2D display, including TFTs, as per http://marc.merlins.org/perso/arduino/post_2020-03-16_Framebuffer_GFX_-Choosing-between-its-3-2D-APIs_-FastLED-XY_-NeoMatrix_-and-LEDMatrix_-and-detail-of-its-many-supported-hardware-backends.html )

Any way to make it bigger?

marcmerlin commented 2 years ago

Demo of what it looks like: https://www.youtube.com/watch?v=PMSQ8xn8EVg

AaronLiddiment commented 2 years ago

I did make a FontDataGenerator windows application that allowed you to select a font and size then it would create the source code for the font header file. It has some issues and doesn't always work prefectly and of course doesn't have any instructions but I could make it available for you if you need it.

marcmerlin commented 2 years ago

Sure, that would be nice, thanks. I also suppose you're not working on the code anymore, but if you are at some point, just having some multiplication factor that would make an existing font 2, 3, or even 5x times bigger, would also be helpful, and not need new fonts. Any chance the fonts can be compatible with adafruit's GFX format? There are plenty of those including online generators. I had one demo that used a font rendered in 10 sizes to do this https://www.youtube.com/watch?v=NRKLB8YhJ6Y

Font code/format: https://github.com/marcmerlin/NeoMatrix-FastLED-IR/blob/master/fonts.h

AaronLiddiment commented 2 years ago

I have added the Font Generator Windows executable to the repository.

marcmerlin commented 2 years ago

Thanks, I tried it, but not sure if I know how to use it.
Can I use char range from 32 to 122 to get lower and uppercase?
Your code adapts to how many characters are in the range, or is it preset to a specific range on your side?

AaronLiddiment commented 2 years ago

Yes, that would be fine. The font header in the output values include the range of characters included. The REDUCE button just trims off the extra spacing that windows puts around some fonts and doesn't always work nicely. The BINARY / UINT8_T option just changes the data format. And the MAKE FONT DATA button will generate the required font header text and put it in the text box ready to be copied into a text / code editor.

marcmerlin commented 2 years ago

got it, thanks

marcmerlin commented 2 years ago

I gave it a shot, with 32-122 fixed width 59 height 57 (reduce), uint_t

generated file: font36.txt

When I run your demo code (demo5), not only the wrong letters are displayed, but also they are offset wrong. Code: LEDText.ino.txt

marcmerlin commented 2 years ago

demo https://www.youtube.com/watch?v=l4JBSpxBdXA (yes, it's running on my computer, I wrote Framebuffer::GFX that allows running any FastLED/LEDMatrix code on a bunch of backends, including TFTs or even just linux)

AaronLiddiment commented 2 years ago

ok. I had never used such a large font so of course it broke the code! I haven't checked the code fully but have just updated the header file with a change that should improve the situation. The changes are: uint8_t m_FontWidth, m_FontHeight, m_FontBase, m_FontUpper, m_FWBytes; uint16_t m_FCBytes; This is because your chosen font file has a single character byte size of 456 which of course exceeds the 8 bit value of the variable m_FCBytes.

marcmerlin commented 2 years ago

Haha, sorry for breaking the type sizes, should have checked that. I broke them in many other places that all assume that a neomatrix will never be bigger than 256x256, which if it's made out of neopixels, is a pretty safe assumption :) The good news is that LEDMatrix does expect up to 65536^2, wihch was a good call on your part, so I've been running Mark Estes' demos on much bigger displays even though they were originally only written for 64x64.

https://marc.merlins.org/perso/arduino/post_2020-03-13_RGB-Panels_-from-192x80_-to-384x192_-to-384x256-and-maybe-not-much-beyond.html and https://www.youtube.com/watch?v=85PI2C6oBsQ

marcmerlin commented 2 years ago

First, thanks for looking at this and helping me with code that you probably haven't looked at for years (last update was 2015 before I started bugging you, sorry :) ). I've had people ask me about scrolling text on RGBPanels, and since my lib allows them to run LEDMatrix and LEDText on top of any backend, including RGBPanels, I pointed them to your code, and then thought I'd start using it for my TFT conference badge too :)

After your fix, it looks better, but now there is still a font overlay problem https://www.youtube.com/watch?v=I2nd6DtQQVQ

You probably don't have a need for this, but if you ever wanted to run your library and arduino code with display on linux (that's what I do, so much easier for coding and debugging), I can help set you up

AaronLiddiment commented 2 years ago

Am very puzzled by the X & y that are overlaid over the h & e, my original example4 doesn't even have a uppercase X in it. Have just had a quick look at the code and if it is an issue in cLEDText then it may be that some explicit uint16_t promotion may need to be added in a few places to make sure no clipping to 8 bit is occuring. I did have a Visual Studio c++ project that allowed me to run Arduino ino projects which in turn allowed line by line debugging but the last time I checked it I think it was broken by a FastLed update at some point.

marcmerlin commented 2 years ago

Do you have linux (even emulation or hypervisor in windows)? If so, I can give you a pre-setup tar that contains everything to compile and run arduino code directly on linux, including SDL emulated FastLED output like in the videos I sent you.

marcmerlin commented 2 years ago

mmmh, or is the font generator broken? here's a screenshot

ss

happy new year!

AaronLiddiment commented 2 years ago

Yep. Thats the issue. Not sure I clean up fully after each font generation. Have also just noticed that when the font is large and there is not enough window bitmap space I stop creating the characters. For the Arial font 36 that you created my generation stops at 'f'. Will try and get a little bit of time today to go through the code. Have a feeling I just stopped laying out characters when the visible display ran out of space. Of course I never used it for fonts this big.

AaronLiddiment commented 2 years ago

Have just updated the FontGenerator with a quick fix. You should find that it now creates enough boxes for the character range you have selected. I have basically just increased the window size. I did note that you window grab shows that the controls are not filling the window which I believe points to you using a % multiplier on the font size. Windows is really bad at scaleable displays. I could make the Generator fully resizable but this will take some work, hopefully the quick fix will do the job.

marcmerlin commented 2 years ago

Thank you, the new generator works better. This is the font I got: fonts36.txt

Things now work ok enough, except for a pretty big space between each letter, not quite sure where it's from. I did use the "reduce" option.

Here is the video result (please forgive the background sound): https://youtu.be/GPLWxde7anU

AaronLiddiment commented 2 years ago

You could change the Fixed option to Proportional before generating the font data. The Reduce option does bring the box in slightly but is still limited by the largest character in the rendered font and as Fixed size will make all characters this size.

marcmerlin commented 2 years ago

Sure enough, I didn't realize that proportional would add such a huge amount of space between letters, but sure enough, you were right, switching to proportional made the problem go away. Thank you for your help, and if I can provide any help with running your lib on any other backend, don't hesitate to ask