Subject: | Glyph::update_bbox doesn't like negative scales |
Date: | Sat, 24 Jan 2009 03:20:21 +0000 |
To: | bug-Font-TTF [...] rt.cpan.org |
From: | Philip Taylor <pjt47 [...] cam.ac.uk> |
Glyph::update_bbox calculates a component glyph's transformed bounding
box ($gnx, $gny, $gxx, $gxy) by multiplying the glyph's bbox with the
scale parameter. If the scale is negative, the min and max values are in
the wrong variables, and so the later bounding box calculations break.
E.g. I have a glyph with scale -1, which initially has values
{ "xMax" => 249, "xMin" => 33, "yMax" => 676, "yMin" => -254 }
After calling update_bbox, it has values
{ "xMax" => 32, "xMin" => 248, "yMax" => -255, "yMin" => 675 }
i.e. min > max which is wrong.
This can be fixed by adding the lines:
($gnx, $gxx) = ($gxx, $gnx) if $gnx > $gxx;
($gny, $gxy) = ($gxy, $gny) if $gny > $gxy;
just after the bit where it sets "($gnx, $gny, $gxx, $gxy) =
($gnx*$sxx+$gny*$syx + $comp->{'args'}[0], ...)"
--
Philip Taylor
pjt47@cam.ac.uk