Bugzilla – Attachment 11031 Details for
Bug 8375
Common diacritics not shown correctly when exporting batch label to PDF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
use truetype fonts in PDF::Reuse
use-truetype-fonts-in-PDFReuse.patch (text/plain), 2.48 KB, created by
Dobrica Pavlinusic
on 2012-07-19 22:04:18 UTC
(
hide
)
Description:
use truetype fonts in PDF::Reuse
Filename:
MIME Type:
Creator:
Dobrica Pavlinusic
Created:
2012-07-19 22:04:18 UTC
Size:
2.48 KB
patch
obsolete
>From 9fde83650080faff82c50dc8b3fda71ff94891aa Mon Sep 17 00:00:00 2001 >From: Dobrica Pavlinusic <dpavlin@rot13.org> >Date: Thu, 19 Jul 2012 23:57:28 +0200 >Subject: [PATCH] use truetype fonts in PDF::Reuse > >Since built-in PDF fonts suport just latin-1 encoding, we have >to switch to truetype fonts to correctly encode all utf-8 characters >(which we should be getting from database anyway). > >This approach also nicely sidesteps our encoding cludges, but >requires paths to truetype fonts, so this example has single >path hard-coded. > >I don't know if it's better to put font path into koha-conf.xml or >can we somehow get it from system. I did try to figure out if >fc-list can display paths, but failed. > >http://bugs.koha-community.org/show_bug.cgi?id=8375 >--- > C4/Creators/PDF.pm | 11 ++++++++--- > labels/label-create-pdf.pl | 7 +++---- > 2 files changed, 11 insertions(+), 7 deletions(-) > >diff --git a/C4/Creators/PDF.pm b/C4/Creators/PDF.pm >index 41ff548..5c3ce8e 100644 >--- a/C4/Creators/PDF.pm >+++ b/C4/Creators/PDF.pm >@@ -55,8 +55,7 @@ sub new { > > 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 >@@ -112,7 +111,13 @@ sub Field { > sub Font { > my $self = shift; > my $fontName = shift; >- return prFont($fontName); >+ my $ttf_path = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf'; >+ if ( -e $ttf_path ) { >+ warn "# using ttf_path $ttf_path"; >+ return prTTFont($ttf_path); >+ } else { >+ return prFont($fontName); >+ } > } > > sub FontSize { >diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl >index 3d7ff1f..e23b068 100755 >--- a/labels/label-create-pdf.pl >+++ b/labels/label-create-pdf.pl >@@ -88,10 +88,9 @@ sub _calc_next_label_pos { > sub _print_text { > my $label_text = shift; > foreach my $text_line (@$label_text) { >- my $pdf_font = $pdf->Font($text_line->{'font'}); >- my $line = "BT /$pdf_font $text_line->{'font_size'} Tf $text_line->{'text_llx'} $text_line->{'text_lly'} Td ($text_line->{'line'}) Tj ET"; >- utf8::decode($line); >- $pdf->Add($line); >+ $pdf->Font($text_line->{'font'}); >+ $pdf->FontSize( $text_line->{'font_size'} ); >+ $pdf->Text( $text_line->{'text_llx'}, $text_line->{'text_lly'}, $text_line->{'line'} ); > } > } > >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8375
:
10651
|
10652
|
10653
|
10654
|
11031
|
12925
|
16548
|
21458
|
26905
|
26906
|
26907
|
26928
|
26976
|
26977
|
26978
|
27335
|
27363
|
27480
|
27482
|
27483
|
27484
|
27917
|
27918
|
37279
|
37285