From 100e95484fd8c46e0cb116df94e577dc59fb2dea Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Mon, 10 Mar 2008 07:10:55 -0400 Subject: [PATCH] Further adjustments on recent label improvments Signed-off-by: Joshua Ferraro --- C4/Labels.pm | 14 +++++++------- labels/label-print-pdf.pl | 19 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/C4/Labels.pm b/C4/Labels.pm index 1a1e8054f2..4740f15100 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -362,13 +362,14 @@ sub GetTextWrapCols { my $string = '0'; my $strwidth; my $count = 0; +# my $textlimit = $label_width - ($left_text_margin); my $textlimit = $label_width - ( 2* $left_text_margin); while ( $strwidth < $textlimit ) { - $count++; $strwidth = prStrWidth( $string, $font, $fontsize ); $string = $string . '0'; #warn "strwidth:$strwidth, textlimit:$textlimit, count:$count string:$string"; + $count++; } return $count; } @@ -835,7 +836,7 @@ sub deduplicate_batch { sub DrawSpineText { - my ( $y_pos, $label_height, $label_width, $font, $fontsize, $x_pos, $left_text_margin, + my ( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, $left_text_margin, $text_wrap_cols, $item, $conf_data, $printingtype ) = @_; # hack to fix column name mismatch betwen labels_conf.class, and bibitems.classification @@ -845,7 +846,6 @@ sub DrawSpineText { $Text::Wrap::separator = "\n"; my $str; - ## $item my $top_text_margin = ( $fontsize + 3 ); #FIXME: This should be a template parameter and passed in... my $line_spacer = ( $fontsize * 0.20 ); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.). @@ -859,9 +859,9 @@ sub DrawSpineText { my $str_fields = get_text_fields($layout_id, 'codes' ); my @fields = split(/ /, $str_fields); #warn Dumper(@fields); - ### @fields my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) ); + my $font = prFont($fontname); # warn Dumper $conf_data; #warn Dumper $item; @@ -897,11 +897,11 @@ sub DrawSpineText { foreach my $str (@strings) { my $hPos; if ( $printingtype eq 'BIB' ) { #FIXME: This is a hack and needs to be implimented as a text justification option in the template... - # some code to try and center each line on the label based on font size and string point length... - my $stringwidth = prStrWidth($str, $font, $fontsize); + # some code to try and center each line on the label based on font size and string point width... + my $stringwidth = prStrWidth($str, $fontname, $fontsize); my $whitespace = ( $label_width - ( $stringwidth + (2 * $left_text_margin) ) ); $hPos = ( ( $whitespace / 2 ) + $x_pos + $left_text_margin ); - warn "\$label_width=$label_width \$stringwidth=$stringwidth \$whitespace=$whitespace \$left_text_margin=$left_text_margin for $str"; + #warn "\$label_width=$label_width \$stringwidth=$stringwidth \$whitespace=$whitespace \$left_text_margin=$left_text_margin for $str\n"; } else { $hPos = ( $x_pos + $left_text_margin ); } diff --git a/labels/label-print-pdf.pl b/labels/label-print-pdf.pl index 68a6b7fc4e..f4d0b4766d 100755 --- a/labels/label-print-pdf.pl +++ b/labels/label-print-pdf.pl @@ -41,11 +41,10 @@ if ($cgi->param('startlabel')) { $start_label = $cgi->param('startlabel'); # A bit of a hack to allow setting the starting label from the address bar... -fbcit } warn "Starting on label #$start_label" if $DEBUG; -my $fontsize = $template->{'fontsize'}; my $units = $template->{'units'}; -warn "UNITS $units"; -warn "fontsize = $fontsize"; +#warn "UNITS $units"; +#warn "fontsize = $fontsize"; #warn Dumper $template; my $unitvalue = GetUnitsValue($units); @@ -88,10 +87,10 @@ prFile(); # Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique # They can be abbreviated: TR, TB, TI, TBI, C, CB, CO, CBO, H, HB, HO, HBO -my $fontname = $template->{'font'}; -my $font = prFont( $fontname ); +my $fontsize = $template->{'fontsize'}; +my $fontname = $template->{'font'}; -my $text_wrap_cols = GetTextWrapCols( $font, $fontsize, $label_width, $left_text_margin ); +my $text_wrap_cols = GetTextWrapCols( $fontname, $fontsize, $label_width, $left_text_margin ); #warn $label_cols, $label_rows; @@ -213,7 +212,7 @@ foreach $item (@resultsloop) { DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width, $barcode, $barcodetype ); - DrawSpineText( $y_pos, $text_height, $label_width, $font, $fontsize, $x_pos, + DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, $left_text_margin, $text_wrap_cols, \$item, \$conf_data ); CalcNextLabelPos(); @@ -224,7 +223,7 @@ foreach $item (@resultsloop) { my $barcode_height = $label_height / 2; DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $barcode, $barcodetype ); - DrawSpineText( $y_pos, $label_height, $label_width, $font, $fontsize, $x_pos, + DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, $left_text_margin, $text_wrap_cols, \$item, \$conf_data ); CalcNextLabelPos(); @@ -236,7 +235,7 @@ foreach $item (@resultsloop) { $barcodetype ); CalcNextLabelPos(); drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox; - DrawSpineText( $y_pos, $label_height, $label_width, $font, $fontsize, $x_pos, + DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, $left_text_margin, $text_wrap_cols, \$item, \$conf_data ); CalcNextLabelPos(); @@ -245,7 +244,7 @@ foreach $item (@resultsloop) { elsif ( $printingtype eq 'BIB' ) { drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox; - DrawSpineText( $y_pos, $label_height, $label_width, $font, $fontsize, $x_pos, + DrawSpineText( $x_pos, $y_pos, $label_height, $label_width, $fontname, $fontsize, $left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype ); CalcNextLabelPos(); }