use PDF::Reuse;
use PDF::Reuse::Barcode;
use File::Temp;
+use List::Util qw/first/;
BEGIN {
use version; our $VERSION = qv('3.07.00.049');
sub End {
my $self = shift;
- # if the pdf stream is utf8, explicitly set it to utf8; this avoids at lease some wide character errors -chris_n
- utf8::encode($PDF::Reuse::stream) if utf8::is_utf8($PDF::Reuse::stream);
+
prEnd();
# slurp temporary filename and print it out for plack to pick up
sub Font {
my $self = shift;
my $fontName = shift;
+
+ my $ttf = C4::Context->config('ttf');
+
+ if ( $ttf ) {
+ my $ttf_path = first { $_->{type} eq $fontName } @{ $ttf->{font} };
+ if ( -e $ttf_path->{content} ) {
+ return prTTFont($ttf_path->{content});
+ } else {
+ warn "ERROR in koha-conf.xml -- missing <font type=\"$fontName\">/path/to/font.ttf</font>";
+ }
+ }
return prFont($fontName);
}
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);
}