From ad3def330cd0696c832f338dcf8b913e0d8e2b35 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 8 Feb 2023 17:04:42 +0800 Subject: [PATCH] Correctly round bearing values while computing pcm * src/sfntfont.c (sfntfont_measure_instructed_pcm) (sfntfont_measure_pcm): Ceil rbearing value. --- src/sfntfont.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sfntfont.c b/src/sfntfont.c index dbd1a037f4a..607ab30afd5 100644 --- a/src/sfntfont.c +++ b/src/sfntfont.c @@ -2277,9 +2277,8 @@ sfntfont_measure_instructed_pcm (struct sfnt_font_info *font, sfnt_glyph glyph, /* Scale the metrics by the interpreter's scale. */ sfnt_scale_metrics (&metrics, font->interpreter->scale); - /* How to round lbearing and rbearing? */ pcm->lbearing = metrics.lbearing >> 16; - pcm->rbearing = outline->xmax >> 16; + pcm->rbearing = SFNT_CEIL_FIXED (outline->xmax) >> 16; /* Round the advance, ascent and descent upwards. */ pcm->width = SFNT_CEIL_FIXED (metrics.advance) >> 16; @@ -2324,7 +2323,7 @@ sfntfont_measure_pcm (struct sfnt_font_info *font, sfnt_glyph glyph, /* How to round lbearing and rbearing? */ pcm->lbearing = metrics.lbearing >> 16; - pcm->rbearing = outline->xmax >> 16; + pcm->rbearing = SFNT_CEIL_FIXED (outline->xmax) >> 16; /* Round the advance, ascent and descent upwards. */ pcm->width = SFNT_CEIL_FIXED (metrics.advance) >> 16; -- 2.39.5