summaryrefslogtreecommitdiff
path: root/src/sfnt.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-12-25 15:38:15 +0800
committerPo Lu <luangruo@yahoo.com>2023-12-25 15:38:15 +0800
commit1be132731d31c3752b275735e5dbe1f60d1988c3 (patch)
tree4b06f212052a83f8d079545aee2edaf56056d395 /src/sfnt.c
parent995dd36da1df70c55ef2e72d4ff5b2641cc83292 (diff)
downloademacs-1be132731d31c3752b275735e5dbe1f60d1988c3.tar.gz
Apply TTF advance width rounding to uninstructed glyphs
* src/sfnt.c (sfnt_scale_metrics): * src/sfntfont.c (sfntfont_get_glyph_outline): Round advance and floor lbearing scaling glyph metrics. (sfntfont_measure_pcm): Don't round or truncate metrics which have already been.
Diffstat (limited to 'src/sfnt.c')
-rw-r--r--src/sfnt.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/sfnt.c b/src/sfnt.c
index d945342c264..b67377ad064 100644
--- a/src/sfnt.c
+++ b/src/sfnt.c
@@ -5656,18 +5656,21 @@ sfnt_lookup_glyph_metrics (sfnt_glyph glyph, int pixel_size,
return 0;
}
-/* Scale the specified glyph metrics by FACTOR.
- Set METRICS->lbearing and METRICS->advance to their current
- values times factor. */
+/* Scale the specified glyph metrics by FACTOR. Set METRICS->lbearing
+ and METRICS->advance to their current values times factor; take the
+ floor of the left bearing and round the advance width. */
MAYBE_UNUSED TEST_STATIC void
sfnt_scale_metrics (struct sfnt_glyph_metrics *metrics,
sfnt_fixed factor)
{
- metrics->lbearing
- = sfnt_mul_fixed (metrics->lbearing * 65536, factor);
- metrics->advance
- = sfnt_mul_fixed (metrics->advance * 65536, factor);
+ sfnt_fixed lbearing, advance;
+
+ lbearing = sfnt_mul_fixed (metrics->lbearing * 65536, factor);
+ advance = sfnt_mul_fixed (metrics->advance * 65536, factor);
+
+ metrics->lbearing = sfnt_floor_fixed (lbearing);
+ metrics->advance = sfnt_round_fixed (advance);
}
/* Calculate the factor used to convert em space to device space for a