]> git.eshelyaron.com Git - emacs.git/commitdiff
Correctly round lbearing values
authorPo Lu <luangruo@yahoo.com>
Tue, 28 Mar 2023 05:39:10 +0000 (13:39 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 28 Mar 2023 05:39:10 +0000 (13:39 +0800)
* src/sfnt.h (SFNT_ROUND_FIXED):
* src/sfntfont.c (sfntfont_probe_widths):
(sfntfont_measure_pcm): Round lbearing properly.

src/sfnt.h
src/sfntfont.c

index fb8cb80bae9257de3c00fd200d24222e6633d947..30c82ad379514c27d2887525a8017d4516d91ed2 100644 (file)
@@ -1325,9 +1325,8 @@ struct sfnt_metrics_distortion
 
 \f
 
-#define SFNT_CEIL_FIXED(fixed)                 \
-  (!((fixed) & 0177777) ? (fixed)              \
-   : ((fixed) + 0200000) & 037777600000)
+#define SFNT_CEIL_FIXED(fixed) (((fixed) + 0177777) & 037777600000)
+#define SFNT_FLOOR_FIXED(fixed) ((fixed) & 037777600000)
 
 \f
 
index 9c0910d18ed9579551d7dc48e93c0dfe516f8aa7..f9965ef13f1a48936a33b3c26cedeba0bba8dac3 100644 (file)
@@ -2460,7 +2460,7 @@ sfntfont_probe_widths (struct sfnt_font_info *font_info)
       num_characters++;
 
       /* Add the advance to total_width.  */
-      total_width += metrics.advance / 65536;
+      total_width += SFNT_CEIL_FIXED (metrics.advance) / 65536;
 
       /* Update min_width if it hasn't been set yet or is wider.  */
       if (font_info->font.min_width == 1
@@ -3183,7 +3183,8 @@ sfntfont_measure_pcm (struct sfnt_font_info *font, sfnt_glyph glyph,
   if (!outline)
     return 1;
 
-  pcm->lbearing = metrics.lbearing / 65536;
+  /* Round the left side bearing downwards.  */
+  pcm->lbearing = SFNT_FLOOR_FIXED (metrics.lbearing) / 65536;
   pcm->rbearing = SFNT_CEIL_FIXED (outline->xmax) / 65536;
 
   /* Round the advance, ascent and descent upwards.  */