Bug 23589: Discharge notice does not show non-latin characters bug_23589
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 2 Oct 2019 09:32:17 +0000 (11:32 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 2 Oct 2019 20:31:07 +0000 (22:31 +0200)
It seems that discarge notices never got support for truetype
fonts, so notices are missing non-latin characters.

Koha/Patron/Discharge.pm

index 5e7595d..4cd596d 100644 (file)
@@ -142,7 +142,25 @@ sub generate_as_pdf {
     else {
         my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
         $pdf->load_file( $html_path );
-        $pdf->convert;
+
+        my $ttf = C4::Context->config('ttf');
+        if ( $ttf  && exists $ttf->{font} ) {
+
+            my $type2path;
+            foreach my $font ( @{ $ttf->{font} } ) {
+                    $type2path->{ $font->{type} } = $font->{content};
+            }
+
+            $pdf->convert(
+                FontBold          => $type2path->{'HB'} || 'HelveticaBold',
+                FontOblique       => $type2path->{'HO'} || 'HelveticaOblique',
+                FontBoldOblique   => $type2path->{'HBO'}|| 'HelveticaBoldOblique',
+                FontUnicode       => $type2path->{'H'}  || 'Helvetica',
+                Font              => $type2path->{'H'}  || 'Helvetica',
+            );
+        } else {
+            $pdf->convert();
+        }
         $pdf->write_file( $pdf_path );
     }