-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text scaling in u8g2 #1919
Comments
This topic has been discussed already several times, so I try to reply with a summary. Any kind of "on the fly" scaling within an embedded system is slow. Of course modern 32 bit systems (ESP32, STM32) may do this, but for 8 bit AVR this is not usefull. As a consequence, u8g2 will not do on the fly scaling, instead it should be done off-line. The mentioned u8x8 scaling is not a real scaling but more a pixel doubling which is still fast. In your case: Select any .ttf font with the desired glyphs, scale this with otf2bdf or fontforge to your desired pixel size, store that font and load the scaled font into your embedded system. |
Thank you for your response. I fully understand your opinion. First, as you have mentioned, the pixel doubling (or scaling with the factor of integers) might be the better word to describe the feature I've requested. Also, I've further investigated regarding my original issue, so I would be glad to redefine the problem and reply to your opinion as follows: The problem was not on converting TTF or OTF font to BDF file or do pixel doubling of the BDF file. The problem occurred when I tried to convert this BDF font to u8g2-compatible font using your bdfconv.exe tool, because it will give an error that the glyph is too large. This is of course a bigger problem when using larger glyphs such as 64 pixel-height glyphs, because size of each glyph is bigger than 256 buffers even after compression. Intentional reduction of details of font by scaling of smaller bdf file to larger bdf file didn't help because the glyph size is still big. For example, I've tried to do pixel quadrupling of 16 pixel-height BDF file to 64 pixel-height BDF (make 1 pixel to 4x4 pixels) to intentionally reduce the details so that the glyphs can be more compressed, but still it does not fit to 256 buffers. Therefore, u8g2 pixel scaling (with the factor of integers) may help to resolve these problems because size of each glyphs will remain small. For example, we can use 16 pixel-height font and do pixel quadrupling to show 64 pixel-height text, which was not possible due to 256 buffers limit; but still fast because we are just performing scaling of pixels by integer values. If we are using high-density display or bigger display, this can be very useful because user may be able to use much larger font which does not fit into 256 buffers restriction. |
Ah, I understand. Integer scaling is more complicated in u8g2 compared to u8x8. |
Thank you for your response, Are there any reasons why integer scaling is complicated compared to u8x8? But it would be really a nice feature for this library to have... |
hmm... we would need to rewrite "u8g2_font_decode_len" procedure Lines 387 to 469 in 7395c68
Would it be ok to ignore font rotation? Maybe like this: Similar to u8x8, we add a "u8g2_font_decode_len_2x2" procedure. But the setFontDirection (https://github.com/olikraus/u8g2/wiki/u8g2reference#setfontdirection) would be ignored. |
Good afternoon, thank you for your response. I was suffering Covid-19 and just saw your response. I am not familiar with the code yet, but I think we can ignore font rotation if it's hard to implement. I will re-check the code and comment it again. Thank you for your work. |
ok, then, let me look into this more deeper. Not sure when I will have time to work on this. |
Added X2 procedures. More testing required... |
looks good, setFontMode is supported |
Added |
Thank you very much!! Let me try on my display to see if this works well... |
Great. New procedures are part of beta 2.33.11 You can download the latest U8g2 beta release from here: https://github.com/olikraus/U8g2_Arduino/archive/master.zip
PlatformIO:
|
Good afternoon, I have tested your code today, by using 32-pixel height font and to display it to 64-pixel height using pixel doubling. The code seems to worked very well on STM32 processor, by using current source code on Github repository. I am attaching the display before and after using pixel doubling. Thank you very much for your work. I really appreciate it. Also, I am sorry for the late reply to your comment. Best regards, |
Great, thanks for the feedback. |
Thank you very much. Do I have to close this issue, or can you close this issue after the announcement of the new version of this U8g2 library? |
I will close this issue once I have checked and updated the documentation. |
doc updated... |
Good afternoon,
First, thank you very much for your wonderful work and library. I've found out that text scaling support has been added to u8x8 library (#41) and it was mentioned that text scaling is not needed in u8g2 library, because fonts with different sizes are provided.
However, I have trouble using u8g2 with Asian characters (like Korean), because there are a lot of glyphs and therefore bigger font size just does not fit to the microcontroller easily. For example, there are only two fonts that supports Korean glyphs (u8g2_font_unifont_t_korean1, u8g2_font_unifont_t_korean2), with same text height.
Therefore, it will be really helpful if we can scale these glyphs for examples from height of 16 to 64 (multiply by 4), to get bigger text in bigger display.
It would be really helpful if you can consider this feature.
Thank you very much.
The text was updated successfully, but these errors were encountered: