comparison 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
comparison
equal deleted inserted replaced
1984:0d5f88e53dca 2041:638eb2d25696
11378 NK_ASSERT(config_list); 11378 NK_ASSERT(config_list);
11379 NK_ASSERT(count); 11379 NK_ASSERT(count);
11380 NK_ASSERT(alloc); 11380 NK_ASSERT(alloc);
11381 11381
11382 if (!image_memory || !width || !height || !config_list || !count) return nk_false; 11382 if (!image_memory || !width || !height || !config_list || !count) return nk_false;
11383 int pixel_area_estimate = 0;
11383 for (config_iter = config_list; config_iter; config_iter = config_iter->next) { 11384 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11384 range_count = nk_range_count(config_iter->range); 11385 range_count = nk_range_count(config_iter->range);
11385 total_range_count += range_count; 11386 total_range_count += range_count;
11386 total_glyph_count += nk_range_glyph_count(config_iter->range, range_count); 11387 int glyphs = nk_range_glyph_count(config_iter->range, range_count);
11388 total_glyph_count += glyphs;
11389 pixel_area_estimate += glyphs * config_iter->size * config_iter->size;
11387 } 11390 }
11388 11391
11389 /* setup font baker from temporary memory */ 11392 /* setup font baker from temporary memory */
11390 for (config_iter = config_list; config_iter; config_iter = config_iter->next) { 11393 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11391 const struct nk_font_config *cfg = config_iter; 11394 const struct nk_font_config *cfg = config_iter;
11392 if (!nk_tt_InitFont(&baker->build[i++].info, (const unsigned char*)cfg->ttf_blob, 0)) 11395 if (!nk_tt_InitFont(&baker->build[i++].info, (const unsigned char*)cfg->ttf_blob, 0))
11393 return nk_false; 11396 return nk_false;
11394 } 11397 }
11395 11398
11396 *height = 0; 11399 *height = 0;
11397 *width = (total_glyph_count > 1000) ? 1024 : 512; 11400 int width_estimate = sqrt(pixel_area_estimate) + 0.5;
11401 *width = 128;
11402 while (*width < width_estimate)
11403 {
11404 *width *= 2;
11405 }
11406 //*width = (total_glyph_count > 1000) ? 1024 : 512;
11398 nk_tt_PackBegin(&baker->spc, 0, (int)*width, (int)max_height, 0, 1, alloc); 11407 nk_tt_PackBegin(&baker->spc, 0, (int)*width, (int)max_height, 0, 1, alloc);
11399 { 11408 {
11400 int input_i = 0; 11409 int input_i = 0;
11401 int range_n = 0; 11410 int range_n = 0;
11402 int rect_n = 0; 11411 int rect_n = 0;