Improve accuracy of computed metrics for FT fonts
In particular, with bitmap fonts, a floating-point error was affecting
y_bearing, yielding a value close to an integer instead of the integer
exactly. The change consists in replacing some operations of the form
A * (1/B)
by A/B
. Details of the issue in #503.
This new code will not always avoid rounding errors in final values when these values could be exact, but it makes some of these errors disappear.
The changes in the src/cairo-ft-font.c
code consists of:
- Define the
SCALE()
macro (with some explanations in a comment). - Remove the declarations and definitions of
x_factor
andy_factor
. - Update the code to use
SCALE()
instead ofx_factor
andy_factor
.
perl -pi -e 's{(DOUBLE_\w+) ?(\(.*\)) \* ([xy])_factor}
{SCALE (\1 \2, unscaled->\3_scale)}' \
src/cairo-ft-font.c
- Replace the remaining
0 * x_factor
and0 * y_factor
by0
.
This replaces the obsolete merge request !232 (closed).