From 6b35c82f9301ffb9cc8f9b24762c8c50dce304e2 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Tue, 8 Apr 2014 20:55:58 -0300 Subject: [PATCH] Bug 8375 - Followup - Fix font code and alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This follow up fixes font code taking it from layout, and alignment. To test: 1. Try making a batch using Helvética, 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 4. Try again 1, now PDF opens 5. Try 2, now alignment is correct --- labels/label-create-pdf.pl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl index e23b068..05fde1a 100755 --- a/labels/label-create-pdf.pl +++ b/labels/label-create-pdf.pl @@ -88,9 +88,19 @@ sub _calc_next_label_pos { sub _print_text { my $label_text = shift; foreach my $text_line (@$label_text) { - $pdf->Font($text_line->{'font'}); + $pdf->Font($layout->get_attr('font')); $pdf->FontSize( $text_line->{'font_size'} ); - $pdf->Text( $text_line->{'text_llx'}, $text_line->{'text_lly'}, $text_line->{'line'} ); + my $llx = $text_line->{'text_llx'}; + my $align = ''; + if ( $layout->get_attr('text_justify') eq 'C' ) { + $llx += $template->get_attr('label_width')/2.0; + $align = 'center'; + } + elsif ( $layout->get_attr('text_justify') eq 'R' ) { + $llx += $template->get_attr('label_width'); + $align = 'right'; + } + $pdf->Text( $llx, $text_line->{'text_lly'}, $text_line->{'line'}, $align ); } } @@ -142,7 +152,6 @@ foreach my $item (@{$items}) { font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), callnum_split => $layout->get_attr('callnum_split'), - justify => $layout->get_attr('text_justify'), format_string => $layout->get_attr('format_string'), text_wrap_cols => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')), ); @@ -165,7 +174,6 @@ foreach my $item (@{$items}) { font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), callnum_split => $layout->get_attr('callnum_split'), - justify => $layout->get_attr('text_justify'), format_string => $layout->get_attr('format_string'), text_wrap_cols => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')), ); @@ -191,7 +199,6 @@ foreach my $item (@{$items}) { font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), callnum_split => $layout->get_attr('callnum_split'), - justify => $layout->get_attr('text_justify'), format_string => $layout->get_attr('format_string'), text_wrap_cols => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')), ); -- 1.7.9.5