Fix _compute_transform to check for nearly degenerate matrices

If a matrix was something like [0 .000001 0, .000001 0 0] the old code would
assume that xx and yy were greater than 0 and turn the nearly degenerate matrix
into an actual degenerate one. This caused things to blow up later on. Now we
check that our nearly rectangular matrices are not nearly degenerate, and let
the nearly degenerate ones fall through to the non-rectangular path.

Note: I'm not sure why NEARLY_ZERO(d) is fabs(d) < 1/65536 instead of some
other value.  Hopefully, it's a useful definition.

This problem was found by a test case attached to:
https://bugzilla.mozilla.org/show_bug.cgi?id=467423
This commit is contained in:
Jeff Muizelaar 2008-12-18 17:07:25 -05:00
parent 0137b9bd32
commit f60da9a379

View file

@ -158,7 +158,8 @@ _compute_transform (cairo_win32_scaled_font_t *scaled_font,
{
cairo_status_t status;
if (NEARLY_ZERO (sc->yx) && NEARLY_ZERO (sc->xy)) {
if (NEARLY_ZERO (sc->yx) && NEARLY_ZERO (sc->xy) &&
!NEARLY_ZERO(sc->xx) && !NEARLY_ZERO(sc->yy)) {
scaled_font->preserve_axes = TRUE;
scaled_font->x_scale = sc->xx;
scaled_font->swap_x = (sc->xx < 0);
@ -166,7 +167,8 @@ _compute_transform (cairo_win32_scaled_font_t *scaled_font,
scaled_font->swap_y = (sc->yy < 0);
scaled_font->swap_axes = FALSE;
} else if (NEARLY_ZERO (sc->xx) && NEARLY_ZERO (sc->yy)) {
} else if (NEARLY_ZERO (sc->xx) && NEARLY_ZERO (sc->yy) &&
!NEARLY_ZERO(sc->yx) && !NEARLY_ZERO(sc->xy)) {
scaled_font->preserve_axes = TRUE;
scaled_font->x_scale = sc->yx;
scaled_font->swap_x = (sc->yx < 0);