sub StrWidth {
my $self = shift;
my ($string, $font, $fontSize) = @_;
+
+ # replace font code with path to TTF font file if need be
+ my $ttf = C4::Context->config('ttf');
+ if ( $ttf ) {
+ my $ttf_path = first { $_->{type} eq $font } @{ $ttf->{font} };
+ if ( -e $ttf_path->{content} ) {
+ $font = $ttf_path->{content};
+ } else {
+ warn "ERROR in koha-conf.xml -- missing <font type=\"$font\">/path/to/font.ttf</font>";
+ }
+ }
+
return prStrWidth($string, $font, $fontSize);
}
ok($pdf_creator->Page(), "testing Page() works");
-is($pdf_creator->StrWidth("test", "H", 12), '19.344', "testing StrWidth() returns correct point width");
+is($pdf_creator->StrWidth("test", "H", 12), '23.044921875', "testing StrWidth() returns correct point width");
@result = $pdf_creator->Text(10, 10, "test");
is($result[0], '10', "testing Text() writes from a given x-value");
-is($result[1], '29.344', "testing Text() writes to the correct x-value");
+is($result[1], '33.044921875', "testing Text() writes to the correct x-value");
open(my $fh, '>', 'test.pdf');
select $fh;