[cairo] [PATCH] ft: correct abs(distance) to fabs(distance)
Behdad Esfahbod
behdad at behdad.org
Thu Mar 21 13:50:09 PDT 2013
Hi Matt,
On 13-03-20 03:12 PM, Matt Sealey wrote:
> Previous commit a8f1b45 ([FT] Prefer downscaling bitmap glyphs to upscaling)
> modified the behavior of Cairo's FT font backend but it seems accidentally
> used abs() with a 'double' type argument. The compiler almost silently
> converts the double to signed integer and then we get the absolute value
> of that signed integer as a signed integer result cast into a double.
Oops.
> The net effect is that min_distance loses precision (fractional part is
> discarded by the compiler's conversion of double -> int) and in some cases
> observed here some fonts do not render correctly if there was any scaling
> involved that actually had a fractional value.
Pushing this out. Though I fail to see how it can cause fonts to not render
correctly. Worst harm it can do is that the wrong strike will be chosen, if
there are strikes very close in size. Right?
behdad
> Signed-off-by: Matt Sealey <matt at genesi-usa.com>
> ---
> src/cairo-ft-font.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
> index 90f410c..1ab56be 100644
> --- a/src/cairo-ft-font.c
> +++ b/src/cairo-ft-font.c
> @@ -759,7 +759,7 @@ _compute_transform (cairo_ft_font_transform_t *sf,
>
> if ((magnify && distance >= 0) || fabs (distance) <= min_distance) {
> magnify = distance < 0;
> - min_distance = abs (distance);
> + min_distance = fabs (distance);
> best_i = i;
> best_x_size = x_size;
> best_y_size = y_size;
>
--
behdad
http://behdad.org/
More information about the cairo
mailing list