diff options
Diffstat (limited to 'src/ftcrfont.c')
-rw-r--r-- | src/ftcrfont.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/ftcrfont.c b/src/ftcrfont.c index 7832d4f5ce0..a10308c62ee 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -139,7 +139,8 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) FcPatternDestroy (pat); font_face = cairo_ft_font_face_create_for_pattern (match); - if (!font_face) + if (!font_face + || cairo_font_face_status (font_face) != CAIRO_STATUS_SUCCESS) { unblock_input (); FcPatternDestroy (match); @@ -154,6 +155,18 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) cairo_font_face_destroy (font_face); cairo_font_options_destroy (options); unblock_input (); + if (!scaled_font + || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS) + { + FcPatternDestroy (match); + return Qnil; + } + ft_face = cairo_ft_scaled_font_lock_face (scaled_font); + if (!ft_face) + { + FcPatternDestroy (match); + return Qnil; + } font_object = font_build_object (VECSIZE (struct font_info), AREF (entity, FONT_TYPE_INDEX), @@ -187,7 +200,8 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) block_input (); cairo_glyph_t stack_glyph; - font->min_width = font->average_width = font->space_width = 0; + font->min_width = font->max_width = 0; + font->average_width = font->space_width = 0; for (char c = 32; c < 127; c++) { cairo_glyph_t *glyphs = &stack_glyph; @@ -211,6 +225,8 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) && (! font->min_width || font->min_width > this_width)) font->min_width = this_width; + if (this_width > font->max_width) + font->max_width = this_width; if (c == 32) font->space_width = this_width; font->average_width += this_width; @@ -231,7 +247,6 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) font->descent = font->height - font->ascent; } - ft_face = cairo_ft_scaled_font_lock_face (scaled_font); if (XFIXNUM (AREF (entity, FONT_SIZE_INDEX)) == 0) { int upEM = ft_face->units_per_EM; @@ -266,6 +281,7 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) font->relative_compose = 0; font->default_ascent = 0; font->vertical_centering = false; + eassert (font->max_width < 512 * 1024 * 1024); return font_object; } |