Bugzilla – Attachment 16548 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]
Bug 8375 - use truetype fonts in PDF::Reuse
Bug-8375---use-truetype-fonts-in-PDFReuse.patch (text/plain), 4.21 KB, created by
Dobrica Pavlinusic
on 2013-03-20 16:40:10 UTC
(
hide
)
Description:
Bug 8375 - use truetype fonts in PDF::Reuse
Filename:
MIME Type:
Creator:
Dobrica Pavlinusic
Created:
2013-03-20 16:40:10 UTC
Size:
4.21 KB
patch
obsolete
>From 4f4f23e4fd4d1354651b816a09e428eb30b85a32 Mon Sep 17 00:00:00 2001 >From: Dobrica Pavlinusic <dpavlin@rot13.org> >Date: Thu, 19 Jul 2012 23:57:28 +0200 >Subject: [PATCH] Bug 8375 - 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 which are included in koha-conf.xml >under new <ttf> section. Without this directive in kona-conf.xml >code will still use latin-1 built-in pdf fonts. >--- > C4/Creators/PDF.pm | 15 +++++++++++++-- > etc/koha-conf.xml | 16 ++++++++++++++++ > labels/label-create-pdf.pl | 7 +++---- > 3 files changed, 32 insertions(+), 6 deletions(-) > >diff --git a/C4/Creators/PDF.pm b/C4/Creators/PDF.pm >index 871e32b..14bc9c4 100644 >--- a/C4/Creators/PDF.pm >+++ b/C4/Creators/PDF.pm >@@ -22,6 +22,7 @@ use warnings; > 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'); >@@ -55,8 +56,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,6 +112,17 @@ sub Field { > 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); > } > >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index ad7bce7..40bae9c 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -294,5 +294,21 @@ __PAZPAR2_TOGGLE_XML_POST__ > <zebra_bib_index_mode>__BIB_INDEX_MODE__</zebra_bib_index_mode> > <zebra_auth_index_mode>__AUTH_INDEX_MODE__</zebra_auth_index_mode> > <queryparser_config>__KOHA_CONF_DIR__/searchengine/queryparser.yaml</queryparser_config> >+ >+ <!-- true type font mapping accoding to type from $font_types in C4/Creators/Lib.pm --> >+ <ttf> >+ <font type="TR" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf</font> >+ <font type="TB" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Bold.ttf</font> >+ <font type="TI" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Italic.ttf</font> >+ <font type="TBI">/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-BoldItalic.ttf</font> >+ <font type="C" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf</font> >+ <font type="CB" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf</font> >+ <font type="CO" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Oblique.ttf</font> >+ <font type="CBO">/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-BoldOblique.ttf</font> >+ <font type="H" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf</font> >+ <font type="HB" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf</font> >+ <font type="HBO">/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-BoldOblique.ttf</font> >+ </ttf> >+ > </config> > </yazgfs> >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