Subject: | Compressed fonts give incorrect metrics |
Test program:
----snip----
my $font1 = Imager::Font->new( file => "FreeSans.ttf" );
my $font2 = Imager::Font->new( file => "FreeSans.ttf" );
$font2->transform ( matrix => Imager::Matrix2d->scale( x => 0.7, y => 1 ) );
my $w;
my $t = "LVAT";
$w = ( $font1->bounding_box( size => 20, string => $t ))[6];
warn( "W = $w\n"); # prints 49
$w = ( $font2->bounding_box( size => 20, string => $t ))[6];
warn( "W = $w\n"); # also prints 49
----snip----
When adding drawing instructions:
----snip----
my $im = Imager->new( xsize => 595, ysize => 892, model => 'rgb' );
$im->string( font => $font1, size => 20, aa => 1, x => 100, y => 100, text => $t );
$im->string( font => $font2, size => 20, aa => 1, x => 100, y => 200, text => $t );
$im->write( file => "test.png" );
----snip----
The resultant image shows that the second text is compressed as desired. Apparently, only the metrics from bounding_box are incorrect.
With font Verdana.ttf, the widths are 51 and 49.
With font TimesNewRomanPSMT.ttf, the widths are 50 and 52 (yes, the condensed font is wider!).