From 845af199157ffb82f93d33682ea9910fb38af8b7 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Sun, 20 Apr 2014 20:23:51 -0300 Subject: [PATCH] Bug 8375: (follow-up) 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. Added a FIXME for the hardcoded forced oblique -chris_n Signed-off-by: Chris Nighswonger Signed-off-by: Galen Charlton --- C4/Creators/Lib.pm | 1 + C4/Labels/Label.pm | 4 +++- etc/koha-conf.xml | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/C4/Creators/Lib.pm b/C4/Creators/Lib.pm index 6fa9bf442a..c519352a60 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 cb6a631d9f..eb2800680c 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -396,6 +396,7 @@ sub draw_label_text { else { $field->{'data'} = _get_barcode_data($field->{'code'},$item,$record); } + #FIXME: We should not force the title to oblique; this should be selectible in the layout configuration ($field->{'code'} eq 'title') ? (($font =~ /T/) ? ($font = 'TI') : ($font = ($font . 'O'))) : ($font = $font); my $field_data = $field->{'data'}; if ($field_data) { @@ -442,7 +443,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 87b538a818..534bd13968 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -125,6 +125,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 -- 2.39.5