aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-13 18:44:30 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-13 18:44:30 +0000
commit9e7106018e9c6552a24d4e236a5e0e74c54c95bb (patch)
treec47e9207e221685da339f9e34cfde393edaa72d9
parentfont: handle invalid glyphs correctly (diff)
font: don't bother creating a cairo surface for zero-width glyphs
-rw-r--r--font.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/font.c b/font.c
index 7ea22f41..8e9eb9b9 100644
--- a/font.c
+++ b/font.c
@@ -364,6 +364,9 @@ glyph_for_wchar(struct font *font, wchar_t wc, struct glyph *glyph)
bitmap->pixel_mode == FT_PIXEL_MODE_GRAY ||
bitmap->pixel_mode == FT_PIXEL_MODE_BGRA);
+ if (bitmap->width == 0)
+ goto err;
+
/* Map FT pixel format to cairo surface format */
cairo_format_t cr_format =
bitmap->pixel_mode == FT_PIXEL_MODE_MONO ? CAIRO_FORMAT_A1 :
@@ -466,7 +469,7 @@ font_glyph_for_wc(struct font *font, wchar_t wc)
assert(font->cache[hash_idx] == NULL);
font->cache[hash_idx] = hash_entry;
}
-
+
assert(hash_entry != NULL);
tll_push_back(*hash_entry, glyph);