emacs-diffs
[Top][All Lists]
Advanced

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

feature/android 2826287b1a3: Correctly round lbearing values


From: Po Lu
Subject: feature/android 2826287b1a3: Correctly round lbearing values
Date: Tue, 28 Mar 2023 01:39:26 -0400 (EDT)

branch: feature/android
commit 2826287b1a3d6661535d631732abd122d460b9fa
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Correctly round lbearing values
    
    * src/sfnt.h (SFNT_ROUND_FIXED):
    * src/sfntfont.c (sfntfont_probe_widths):
    (sfntfont_measure_pcm): Round lbearing properly.
---
 src/sfnt.h     | 5 ++---
 src/sfntfont.c | 5 +++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/sfnt.h b/src/sfnt.h
index fb8cb80bae9..30c82ad3795 100644
--- a/src/sfnt.h
+++ b/src/sfnt.h
@@ -1325,9 +1325,8 @@ struct sfnt_metrics_distortion
 
 
 
-#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)
 
 
 
diff --git a/src/sfntfont.c b/src/sfntfont.c
index 9c0910d18ed..f9965ef13f1 100644
--- a/src/sfntfont.c
+++ b/src/sfntfont.c
@@ -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.  */



reply via email to

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