From 3368e91adc5b97e5f0459144b288ed2e99f700e0 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Sun, 20 Apr 2014 20:23:51 -0300 Subject: [PATCH] Bug 8375 - Followup - Fix font code and alignment This patch fixes two problems: a) Bad PDF when using Helvetica font. Current label code assigns 'italic' or 'oblique' variants to title. Helvetica-Oblique was not defined, but is present b) Bad alignment using center/right justification Problem was bad font parameter passed to StrWidth routine To test: 1. Try making a batch using Helvetica, downloaded PDF do not open. 2. Try a batch of mixed scripts with layout alignment center or right, only latin scripts align almost correctly. 3. Apply the patch and update your koha-conf.xml to add Oblique variant 4. Try again 1, now PDF opens 5. Try 2, now alignment is correct New problem (for another bug): DejaVuSans has a good support for arabic, but not Oblique variant. As selection of italic/oblique is hardcoded, now Arabic titles are not displayed. I'll try to add a checkbox to select or not this feature. --- C4/Creators/Lib.pm | 1 + C4/Labels/Label.pm | 3 ++- etc/koha-conf.xml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/C4/Creators/Lib.pm b/C4/Creators/Lib.pm index 6fa9bf4..c519352 100644 --- a/C4/Creators/Lib.pm +++ b/C4/Creators/Lib.pm @@ -119,6 +119,7 @@ my $font_types = [ {type => 'CO', name => 'Courier-Oblique', selected => 0}, {type => 'CBO', name => 'Courier-Bold-Oblique', selected => 0}, {type => 'H', name => 'Helvetica', selected => 0}, + {type => 'HO', name => 'Helvetica-Oblique', selected => 0}, {type => 'HB', name => 'Helvetica-Bold', selected => 0}, {type => 'HBO', name => 'Helvetica-Bold-Oblique', selected => 0}, ]; diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index cb6a631..e8ba973 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -442,7 +442,8 @@ sub draw_label_text { LABEL_LINES: # generate lines of label text for current field foreach my $line (@label_lines) { next LABEL_LINES if $line eq ''; - my $string_width = C4::Creators::PDF->StrWidth($line, $font, $self->{'font_size'}); + my $fontName = C4::Creators::PDF->Font($font); + my $string_width = C4::Creators::PDF->StrWidth($line, $fontName, $self->{'font_size'}); if ($self->{'justify'} eq 'R') { $text_llx = $params{'llx'} + $self->{'width'} - ($self->{'left_text_margin'} + $string_width); } diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml index 566318e..710deb5 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -311,6 +311,7 @@ __PAZPAR2_TOGGLE_XML_POST__ /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Oblique.ttf /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-BoldOblique.ttf /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf + /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-BoldOblique.ttf -- 1.7.9.5