From cb267f4302d4ec6234484463cd85ff9c67b90843 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 16 May 2022 09:48:32 -0700 Subject: [PATCH] unknown glyph renders a space --- src/FontAtlas.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/FontAtlas.zig b/src/FontAtlas.zig index fa75d6b41..0ade9e460 100644 --- a/src/FontAtlas.zig +++ b/src/FontAtlas.zig @@ -122,10 +122,14 @@ pub fn addGlyph(self: *FontAtlas, alloc: Allocator, v: anytype) !*Glyph { if (gop.found_existing) return gop.value_ptr; errdefer _ = self.glyphs.remove(utf32); - const glyph_index = ftc.FT_Get_Char_Index(self.ft_face, utf32); + const glyph_index = glyph_index: { + const idx = ftc.FT_Get_Char_Index(self.ft_face, utf32); + if (idx > 0) break :glyph_index idx; - // TODO: probably not an error because we want to add a box. - if (glyph_index == 0) return error.CodepointNotFound; + // Unknown glyph. + // TODO: render something more identifiable than a space + break :glyph_index ftc.FT_Get_Char_Index(self.ft_face, ' '); + }; if (ftc.FT_Load_Glyph( self.ft_face,