]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle Cairo errors in ftcrfont_open
authorPip Cet <pipcet@gmail.com>
Thu, 22 Oct 2020 11:40:34 +0000 (13:40 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 22 Oct 2020 11:40:34 +0000 (13:40 +0200)
* src/ftcrfont.c (ftcrfont_open): Handle Cairo errors (bug#41627).

src/ftcrfont.c

index 4892a34a3ab70ff813819f46ac40c96d09e7df57..a10308c62eebef9463f81a4b2beb383e4ad4e853 100644 (file)
@@ -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),
@@ -234,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;