Bug 8375: (follow-up) fix font code and alignment
authorBernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Sun, 20 Apr 2014 23:23:51 +0000 (20:23 -0300)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 5 May 2014 21:55:16 +0000 (21:55 +0000)
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 <cnighswonger@foundations.edu>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Creators/Lib.pm
C4/Labels/Label.pm
etc/koha-conf.xml

index 6fa9bf4..c519352 100644 (file)
@@ -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},
 ];
index cb6a631..eb28006 100644 (file)
@@ -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);
             }
index 87b538a..534bd13 100644 (file)
@@ -125,6 +125,7 @@ __PAZPAR2_TOGGLE_XML_POST__
     <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="HO" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.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>