diff --git a/nuklear.h b/nuklear.h index 7c33ba63d..cb9830cfe 100644 --- a/nuklear.h +++ b/nuklear.h @@ -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; @@ -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; diff --git a/src/nuklear_font.c b/src/nuklear_font.c index 6d79b016b..59a92c019 100644 --- a/src/nuklear_font.c +++ b/src/nuklear_font.c @@ -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; @@ -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... */ + 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;