diff --git a/fonts.d b/fonts.d index 9b4b0cf..53d229a 100644 --- a/fonts.d +++ b/fonts.d @@ -114,11 +114,13 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension) u32 current_h = 0; u32 count = 0; - FT_UInt index; - FT_ULong char_code = FT_Get_First_Char(font, &index); - while (index != 0) + foreach(FT_ULong char_code; 0 .. 0x7F) { - FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER); + FT_Error res = FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER); + if (res != 0) + { + continue; + } u32 bmp_w = font.glyph.bitmap.width; u32 bmp_h = font.glyph.bitmap.rows; @@ -133,8 +135,6 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension) max_w += bmp_w; current_h = bmp_h > current_h ? bmp_h : current_h; count += 1; - - char_code = FT_Get_Next_Char(font, char_code, &index); } atlas.atlas.glyphs = AllocArray!(Glyph)(arena, count); @@ -147,10 +147,13 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension) u32 font_w = font.size.metrics.x_ppem; u32 font_h = font.size.metrics.y_ppem; - char_code = FT_Get_First_Char(font, &index); - while (index != 0) + foreach(FT_ULong char_code; 0 .. 0x7F) { - FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER); + FT_Error res = FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER); + if (res != 0) + { + continue; + } FT_GlyphSlot glyph = font.glyph; FT_Bitmap* bmp = &font.glyph.bitmap; @@ -196,8 +199,6 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension) max_w += bmp.width; current_h = bmp.rows > current_h ? bmp.rows : current_h; - char_code = FT_Get_Next_Char(font, char_code, &index); - count += 1; }