sub setTTFont {
my ( $self, $fontfile, $size )= @_;
if (exists $self->{__font_cache}->{$fontfile}) {
$self->{font} = $self->{__font_cache}->{$fontfile};
}
else {
$self->{font} = $self->{pdf}->ttfont($fontfile);
$self->{__font_cache}->{$fontfile} = $self->{font};
}
$self->{fontname} = $fontfile;
}
In other words, pretty much exactly the same as ->setFont(), but calling ->ttfont() rather than ->corefont() on the underlying PDF::API2 object.
(Notes - a) this'd go into PDF::Report, of course, not your script; b) completely untested; c) uses the same fontcache as ->setFont(), which may or may not be a good design choice; d) could be refactored to avoid code duplication (e.g. have this and ->setFont() call an internal helper routine).)
|