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
instruction code or glyph variation. The left side
bearing is the distance from the origin point to the
left most point on the X axis. */
- temp.lbearing = outline->xmin - outline->origin;
+ temp.lbearing
+ = SFNT_FLOOR_FIXED (outline->xmin - outline->origin);
}
}
}
if (!outline)
return 1;
- /* Round the left side bearing down. */
- pcm->lbearing = SFNT_FLOOR_FIXED (metrics.lbearing) / 65536;
+ /* The left side bearing has already been floored. */
+ pcm->lbearing = metrics.lbearing / 65536;
pcm->rbearing = SFNT_CEIL_FIXED (outline->xmax) / 65536;
- /* Round the advance, ascent and descent upwards. */
- pcm->width = SFNT_CEIL_FIXED (metrics.advance) / 65536;
+ /* The advance is already rounded; ceil the ascent and descent. */
+ pcm->width = metrics.advance / 65536;
pcm->ascent = SFNT_CEIL_FIXED (outline->ymax) / 65536;
pcm->descent = SFNT_CEIL_FIXED (-outline->ymin) / 65536;