emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 27d28d4: Make ftcr font backend driver more consist


From: YAMAMOTO Mitsuharu
Subject: [Emacs-diffs] master 27d28d4: Make ftcr font backend driver more consistent with xft
Date: Sat, 22 Jun 2019 02:34:46 -0400 (EDT)

branch: master
commit 27d28d43d12999cf04d823ec9e08228d1b862a49
Author: YAMAMOTO Mitsuharu <address@hidden>
Commit: YAMAMOTO Mitsuharu <address@hidden>

    Make ftcr font backend driver more consistent with xft
    
    * src/ftcrfont.c (ftcrfont_open): Use metrics of glyph ID 0 if there is no
    glyph for an ASCII printable.
---
 src/ftcrfont.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index a019fe8..0cc40b4 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -187,7 +187,6 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int 
pixel_size)
 
   block_input ();
   cairo_glyph_t stack_glyph;
-  int n = 0;
   font->min_width = font->average_width = font->space_width = 0;
   for (char c = 32; c < 127; c++)
     {
@@ -198,28 +197,25 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int 
pixel_size)
                                          0, 0, &c, 1, &glyphs, &num_glyphs,
                                          NULL, NULL, NULL);
 
-      if (status == CAIRO_STATUS_SUCCESS)
+      /* In order to simulate the Xft behavior, we use metrics of
+        glyph ID 0 if there is no glyph for an ASCII printable.  */
+      if (status != CAIRO_STATUS_SUCCESS)
+       stack_glyph.index = 0;
+      else if (glyphs != &stack_glyph)
        {
-         if (glyphs != &stack_glyph)
-           cairo_glyph_free (glyphs);
-         else if (stack_glyph.index)
-           {
-             int this_width = ftcrfont_glyph_extents (font, stack_glyph.index,
-                                                      NULL);
-
-             if (this_width > 0
-                 && (! font->min_width
-                     || font->min_width > this_width))
-               font->min_width = this_width;
-             if (c == 32)
-               font->space_width = this_width;
-             font->average_width += this_width;
-             n++;
-           }
+         cairo_glyph_free (glyphs);
+         stack_glyph.index = 0;
        }
+      int this_width = ftcrfont_glyph_extents (font, stack_glyph.index, NULL);
+      if (this_width > 0
+         && (! font->min_width
+             || font->min_width > this_width))
+       font->min_width = this_width;
+      if (c == 32)
+       font->space_width = this_width;
+      font->average_width += this_width;
     }
-  if (n > 0)
-    font->average_width /= n;
+  font->average_width /= 95;
 
   cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents);
   font->ascent = lround (extents.ascent);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]