added ttf fonts
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 11 Sep 2019 11:17:01 +0000 (13:17 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 11 Sep 2019 11:17:01 +0000 (13:17 +0200)
lib/Koha/Patron/Discharge.pm

index 3fbdc34..0af934a 100644 (file)
@@ -142,9 +142,40 @@ sub generate_as_pdf {
     else {
         my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
         $pdf->load_file( $html_path );
     else {
         my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
         $pdf->load_file( $html_path );
-=for params
-=cut
-        $pdf->convert;
+
+               my $ttf = C4::Context->config('ttf');
+               if ( $ttf  && exists $ttf->{font} ) {
+
+                       use Data::Dump qw(dump);
+warn "XXX ttf = ",dump($ttf);
+
+                       my $type2path;
+                       foreach my $font ( @{ $ttf->{font} } ) {
+                                       $type2path->{ $font->{type} } = $font->{content};
+                       }
+
+                       warn "# type2path = ",dump($type2path);
+
+
+               $pdf->convert(
+#                              PageWidth         640
+#                              PageResolution    540
+#                              FontBold          'HelveticaBold'
+#                              FontOblique       'HelveticaOblique'
+#                              FontBoldOblique   'HelveticaBoldOblique'
+#                              LineHeight        12
+#                              FontUnicode       'Helvetica'
+#                              Font              (same as FontUnicode)
+#                              PageSize          'A4'
+#                              Landscape         0
+
+                               FontBold          => $type2path->{'HB'} || 'HelveticaBold',
+                               FontOblique       => $type2path->{'HO'} || 'HelveticaOblique',
+                               FontBoldOblique   => $type2path->{'HBO'}|| 'HelveticaBoldOblique',
+                               FontUnicode       => $type2path->{'H'}  || 'Helvetica',
+                               Font              => $type2path->{'H'}  || 'Helvetica',
+                       );
+               }
         $pdf->write_file( $pdf_path );
     }
 
         $pdf->write_file( $pdf_path );
     }