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;
}
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
$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.).
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;
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 );
}
$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);
# 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;
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();
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();
$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();
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();
}