Skip to content

fix: nk_font_config oversampling 3x horizontaly by default#973

Open
sleeptightAnsiC wants to merge 2 commits into
Immediate-Mode-UI:masterfrom
sleeptightAnsiC:fix_font_oversample_h
Open

fix: nk_font_config oversampling 3x horizontaly by default#973
sleeptightAnsiC wants to merge 2 commits into
Immediate-Mode-UI:masterfrom
sleeptightAnsiC:fix_font_oversample_h

Conversation

@sleeptightAnsiC

@sleeptightAnsiC sleeptightAnsiC commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

See linked issue for additional information.

According to the commit that introduced this, it was supposed to: "oversample the default font to make it look better" but it was oversampling every single font, potentially making it blurry. This fix preserves old behavior for code that may still expect it, but nk_font_config will now use oversample_h=1 by default. Some demos achieve sharp font by scaling their pixel_size and in this case there won't be any difference, but if someone used badly behaving font and didn't notice it only worked because of oversampling, that font may now appear differently (this is unlikely but still possible).

Fixes: #855
Refs: 1d7f024

DO NOT SQUASH

@sleeptightAnsiC sleeptightAnsiC force-pushed the fix_font_oversample_h branch from d33b79a to bcc8da8 Compare July 1, 2026 23:02
Comment thread src/nuklear_font.c
Comment on lines +1185 to +1186
config = nk_font_config(0);
config.oversample_h = 3;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I felt tempted to remove it even from here, but after testing a bit, it appears that some rawfb demos indeed look worse without it. Again, that probably just happens to work and there is most likely a better way to achieve it, but I don't want to cause any unnecessary breakage.

Comment thread src/nuklear_font.c
Comment on lines +1176 to +1182
/* FIXME(sleeptightAnsiC): This "fallback" exists for compatibility
* with code that creates empty atlas and immediately bakes it.
* Several demos do this, but it doesn't make sense for API to allow it.
* It was never documented anywhere and it's more of a hack than feature.
* App/backend should call nk_font_atlas_add_default() on it's own
* with whatever config it wants, and treat it like any other font.
* Worth to consider this for removal during next major release... */

@sleeptightAnsiC sleeptightAnsiC Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FIXME comment is pretty much unrelated to PR, but since I already invested some time into understanding this code, I thought I would simply put it here. I can split it into another commit, if it's a big deal. EDIT: I just moved this to another commit.

See linked issue for additional information.
According to the commit that introduced this, it was supposed to:
_"oversample the default font to make it look better_"
but it was oversampling every single font, potentially making it blurry.
This fix preserves old behavior for code that may still expect it,
but nk_font_config will now use oversample_h=1 by default.
Some demos achieve sharp font by scaling their pixel_size and in this
case there won't be any difference, but if someone used badly behaving font
and didn't notice it only worked because of oversampling, that font
may now appear differently (this is unlikely but still possible).

Fixes: Immediate-Mode-UI#855
Refs: Immediate-Mode-UI@1d7f024
split into another commit in case the previous one will need to be reverted
@sleeptightAnsiC sleeptightAnsiC force-pushed the fix_font_oversample_h branch from bcc8da8 to e7a8bef Compare July 4, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Font baking issue.

1 participant