From 3cdc08f0e1e736d3f95ae01090d3c24aeab9cd37 Mon Sep 17 00:00:00 2001 From: PanuiQ <62739290+PanuiQ@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:50:42 +0800 Subject: [PATCH] Update makefont.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix bug, in making Texture glyphs codes , if glyph->codepoint >256 , The curly braces of the generated file do not match --- makefont.c | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/makefont.c b/makefont.c index ecb84a9..a60a8cd 100644 --- a/makefont.c +++ b/makefont.c @@ -527,22 +527,42 @@ int main( int argc, char **argv ) // -------------- // Texture glyphs // -------------- - fprintf( file, " {\n" ); - GLYPHS_ITERATOR1(i, glyph, font->glyphs) { - fprintf( file, " {\n" ); - GLYPHS_ITERATOR2(i, glyph, font->glyphs) { - fprintf( file, " &%s_glyph_%08x,\n", variable_name, glyph->codepoint ); - } else { - fprintf( file, " NULL,\n" ); - } - GLYPHS_ITERATOR_END1; - fprintf( file, " },\n" ); - } GLYPHS_ITERATOR_END2; - fprintf( file, " }\n};\n" ); - fprintf( file, + + fprintf(file, " {\n"); + for (int index = 0; index < vector_size(font->glyphs); index++) + { + { + texture_glyph_t** __glyphs; + if ((__glyphs = *(texture_glyph_t***)vector_get(font->glyphs, index))) + { + int __i; + fprintf(file, " {\n"); + for (__i = 0; __i < 0x100; __i++) + { + if ((glyph = __glyphs[__i])) + { + fprintf(file, " &%s_glyph_%08x,\n", variable_name, glyph->codepoint); + } + else + { + fprintf(file, " NULL,\n"); + } + }; + fprintf(file, " },\n"); + } + else + { + fprintf(file, "{NULL},\n"); + } + } + }; + + fprintf(file, " }\n};\n"); + + fprintf(file, "#ifdef __cplusplus\n" "}\n" - "#endif\n" ); + "#endif\n"); return 0; }