Skip Menu |

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 111450
Status: open
Priority: 90/
Queue: Imager

People
Owner: Nobody in particular
Requestors: jv [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.004
Fixed in: (no value)



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!).
On Tue Jan 26 15:09:09 2016, JV wrote: Show quoted text
> 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!).
This is the documented behaviour, from Imager::Font: The transformation matrix set by L</transform()> has no effect on the result of this method - the bounds of the untransformed text is returned. Tony