Skip to content
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

Large font support #3332

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

pwasmund
Copy link

Added 4 larger font sizes by adding four console_font_XXxYY.h files and modifying the routine Segment::drawCharacter() to handle fonts that used more than 1 byte to define a horizontal row of pixels.

Copy link
Collaborator

@blazoncek blazoncek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Font with height 56 lines may be unjustified (having matrix with height larger than 56 lines is very uncommon and requires special handling) as it eats plenty of flash storage.
I also consider reading directly from flash memory a bad practice (Espressif recommends using pgm_read…()).

And finally since code size for regular WLED, which may include a usermod or two, is already reaching beyond 95% of file system size I'd like to see this enhancement as a custom compile option.

wled00/FX.cpp Outdated
case 6: letterWidth = 12; letterHeight = 16; break;
case 7: letterWidth = 12; letterHeight = 24; break;
case 8: letterWidth = 16; letterHeight = 32; break;
case 9: letterWidth = 25; letterHeight = 57; break;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason to use characters with height above 32 as matrices with such dimensions become unmanageable.
Also font memory footprint becomes very large and we want to avoid that.

case 48: bits = pgm_read_byte_near(&console_font_6x8[(chr * h) + i]); break; // 6x8 font
case 63: bits = pgm_read_byte_near(&console_font_7x9[(chr * h) + i]); break; // 7x9 font
case 60: bits = pgm_read_byte_near(&console_font_5x12[(chr * h) + i]); break; // 5x12 font
case 24: bits = &console_font_4x6[(chr * h * num_bytes) + (i * num_bytes)]; break; // 5x8 font
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea to manipulate flash memory directly is bad and against recommended practices. Use bits as it was intended - a regular variable, not pointer.

int wb = w % 8;
if(wb == 0)
wb = 8; // get width of the first byte to process
for (int k = 1; k <= num_bytes; k++) { // loop through all bytes of the character
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check fx-blending branch to see planned enhancements to scrolling text and drawCharacter() function and accomodate that.
You may need to wait until fx-blending is merged to update this PR.

Comment on lines +565 to +568
#include "src/font/console_font_12x16.h"
#include "src/font/console_font_12x24.h"
#include "src/font/console_font_16x32.h"
#include "src/font/console_font_25x57.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to make large fonts optional compile.
Please accommodate that.

void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2) {
if (!isActive()) return; // not active
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though we added measures elsewhere this should remain here to prevent crash if segment changes during writing to it.

Comment on lines 580 to 594
if (w <= 8) {
num_bytes = 1;
}
else if(w <= 16){
num_bytes = 2;
}
else if (w <= 24){
num_bytes = 3;
}
else if (w <= 32){
num_bytes = 4;
}
else {
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple switch () may be cleaner.

Removed the console_font_25x57 font, created the WLED_ENABLE_LARGE_FONTS define to conditional compile the large font code and fonts, merged changes needed from the fx-blending branch and other minor cleanup.
@Aircoookie
Copy link
Owner

Another way to achieve huge fonts on large matrices is using Grouping 2 or 3, which will render to a smaller virtual segment and scale up. Since that approach leads to blockier character edges though, this PR is of course valid. Just pointing out there's a way to render large fonts at all without additional flash use.

Copy link

Hey! This pull request has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
Thank you for contributing to WLED! ❤️

@github-actions github-actions bot added the stale This issue will be closed soon because of prolonged inactivity label Apr 15, 2024
@softhack007
Copy link
Collaborator

softhack007 commented Apr 15, 2024

Hey! This pull request has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs. Thank you for contributing to WLED! ❤️

@blazoncek @w00000dy I think we should exclude pull requests from the "auto-close" stale.yaml. Or maybe lets mark then "stale", but don't auto-close them after a week.

@softhack007 softhack007 added the keep This issue will never become stale/closed automatically label Apr 15, 2024
@w00000dy
Copy link
Contributor

Hey! This pull request has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs. Thank you for contributing to WLED! ❤️

@blazoncek @w00000dy I think we should exclude pull requests from the "auto-close" stale.yaml. Or maybe lets mark then "stale", but don't auto-close them after a week.

Could be done like this. Let's see what @blazoncek says.

@blazoncek
Copy link
Collaborator

Let's see if stale is removed since keep was added to the tags/labels.
I am in favour of marking PRs worth of merging (but the ones that need a bit more work or reviews) with keep tag/label.

The issue with this particular PR is that it adds a few more bytes to flash footprint which may be problematic in the near future.

@w00000dy
Copy link
Contributor

Let's see if stale is removed since keep was added to the tags/labels. I am in favour of marking PRs worth of merging (but the ones that need a bit more work or reviews) with keep tag/label.

The issue with this particular PR is that it adds a few more bytes to flash footprint which may be problematic in the near future.

By looking into the log we can see that it does not remove the stale label, because keep was set:
[#3332] Skipping this pull request because it contains an exempt label, see exempt-pr-labels (​https://github.com/actions/stale#exempt-pr-labels​)) for more details

So in cases like this one you would have to manually remove the stale label or ignore it.

@blazoncek
Copy link
Collaborator

@softhack007 why would you want to keep this PR open? I have no intention of merging it as it is. Do you see otherwise?

@softhack007
Copy link
Collaborator

softhack007 commented Apr 20, 2024

@softhack007 why would you want to keep this PR open? I have no intention of merging it as it is. Do you see otherwise?

@blazoncek yes I see some potential for this PR plus the other "tiny font" PR #3337 - if its it's made optional for compile AND requested changes are implemented. At least on devices like S3 with more program space in flash.

So not for genral use, but for larger fixtures, e.g. setups using HUB75 (PR #3777). That's why I feel it should not be closed yet.

@blazoncek blazoncek added waiting for feedback addition information needed to better understand the issue and removed stale This issue will be closed soon because of prolonged inactivity labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effect keep This issue will never become stale/closed automatically waiting for feedback addition information needed to better understand the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants