diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-20 21:00:26 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-20 21:00:26 -0500 |
| commit | 76a38d7f972b17c33a6ffd6dc3772df721139e67 (patch) | |
| tree | bee9b1edd87ff6ebe6eb1e9687a4ca0858052f9c /editor | |
| parent | 09989000cd5787578c0676b279d3ecbc9ca50524 (diff) | |
pke: chkpt: minimum required unicode chars
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index ed1b017..e3f6b7c 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -715,6 +715,13 @@ int SortFontGlyphChar(const void *a, const void *b) { } void GenerateMTSDF(FontTypeMSDFSettings *msdf_settings, const Asset *a) { + static const uint64_t REQUIRED_UNICODE_CHAR_LENGTH = 3; + static uint32_t required_unicode_codes[REQUIRED_UNICODE_CHAR_LENGTH] = { + 9, // horizontal tab + 10, // line feed + 13, // carriage return + }; + uint64_t found_unicode_map = 0; assert(PK_HAS_FLAG(a->type, PKE_ASSET_TYPE_FONT)); FontTypeSpacing ft_spacing{}; glm::dvec4 dbounds; @@ -798,6 +805,13 @@ void GenerateMTSDF(FontTypeMSDFSettings *msdf_settings, const Asset *a) { arr[i].unicode = glyphs[i].getCodepoint(); arr[i].is_whitespace = glyphs[i].isWhitespace(); + for (uint64_t k = 0; k < REQUIRED_UNICODE_CHAR_LENGTH; ++k) { + if (arr[i].unicode == required_unicode_codes[k]) { + found_unicode_map |= (1ull << k); + break; + } + } + glyphs[i].getQuadPlaneBounds(dbounds.x, dbounds.y, dbounds.z, dbounds.a); arr[i].plane_bounds = dbounds; @@ -806,6 +820,17 @@ void GenerateMTSDF(FontTypeMSDFSettings *msdf_settings, const Asset *a) { arr[i].sprite_region_min = glm::vec2(dbounds.x, height - dbounds.a); arr[i].sprite_region_max = glm::vec2(dbounds.z, height - dbounds.y); } + + for (uint64_t k = 0; k < REQUIRED_UNICODE_CHAR_LENGTH; ++k) { + if ((found_unicode_map & (1ull << k)) != 0) { + continue; + } + FontGlyphChar fgc{}; + memset(&fgc, 0, sizeof(FontGlyphChar)); + fgc.unicode = required_unicode_codes[k]; + pk_arr_append(&arr_glyphs, &fgc); + } + qsort(arr_glyphs.data, arr_glyphs.next, arr_glyphs.stride, SortFontGlyphChar); auto f = fopen(path_glyphs, "w+"); |
