Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -17713,7 +17713,7 @@ nk_font_config(float pixel_height)
cfg.ttf_size = 0;
cfg.ttf_data_owned_by_atlas = 0;
cfg.size = pixel_height;
cfg.oversample_h = 3;
cfg.oversample_h = 1;
cfg.oversample_v = 1;
cfg.pixel_snap = 0;
cfg.coord_type = NK_COORD_UV;
Expand Down Expand Up @@ -18021,9 +18021,21 @@ nk_font_atlas_bake(struct nk_font_atlas *atlas, int *width, int *height,

#ifdef NK_INCLUDE_DEFAULT_FONT
/* no font added so just use default font */
if (!atlas->font_num)
atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
/* 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... */
if (!atlas->font_num) {
struct nk_font_config config;
config = nk_font_config(0);
config.oversample_h = 3;
atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, &config);
}
#endif

NK_ASSERT(atlas->font_num);
if (!atlas->font_num) return 0;

Expand Down
18 changes: 15 additions & 3 deletions src/nuklear_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ nk_font_config(float pixel_height)
cfg.ttf_size = 0;
cfg.ttf_data_owned_by_atlas = 0;
cfg.size = pixel_height;
cfg.oversample_h = 3;
cfg.oversample_h = 1;
cfg.oversample_v = 1;
cfg.pixel_snap = 0;
cfg.coord_type = NK_COORD_UV;
Expand Down Expand Up @@ -1173,9 +1173,21 @@ nk_font_atlas_bake(struct nk_font_atlas *atlas, int *width, int *height,

#ifdef NK_INCLUDE_DEFAULT_FONT
/* no font added so just use default font */
if (!atlas->font_num)
atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
/* 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... */
Comment on lines +1176 to +1182

@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.

if (!atlas->font_num) {
struct nk_font_config config;
config = nk_font_config(0);
config.oversample_h = 3;
Comment on lines +1185 to +1186

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.

atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, &config);
}
#endif

NK_ASSERT(atlas->font_num);
if (!atlas->font_num) return 0;

Expand Down
Loading