Mercurial > repos > blastem
diff nuklear_ui/nuklear.h @ 2041:638eb2d25696 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 05 Aug 2021 09:29:33 -0700 |
parents | 374a5ae694e8 579fe3f6fe76 |
children |
line wrap: on
line diff
--- a/nuklear_ui/nuklear.h Sun May 10 00:16:00 2020 -0700 +++ b/nuklear_ui/nuklear.h Thu Aug 05 09:29:33 2021 -0700 @@ -11380,10 +11380,13 @@ NK_ASSERT(alloc); if (!image_memory || !width || !height || !config_list || !count) return nk_false; + int pixel_area_estimate = 0; for (config_iter = config_list; config_iter; config_iter = config_iter->next) { range_count = nk_range_count(config_iter->range); total_range_count += range_count; - total_glyph_count += nk_range_glyph_count(config_iter->range, range_count); + int glyphs = nk_range_glyph_count(config_iter->range, range_count); + total_glyph_count += glyphs; + pixel_area_estimate += glyphs * config_iter->size * config_iter->size; } /* setup font baker from temporary memory */ @@ -11394,7 +11397,13 @@ } *height = 0; - *width = (total_glyph_count > 1000) ? 1024 : 512; + int width_estimate = sqrt(pixel_area_estimate) + 0.5; + *width = 128; + while (*width < width_estimate) + { + *width *= 2; + } + //*width = (total_glyph_count > 1000) ? 1024 : 512; nk_tt_PackBegin(&baker->spc, 0, (int)*width, (int)max_height, 0, 1, alloc); { int input_i = 0;