Further adjustments on recent label improvments
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
ff8982f318
commit
100e95484f
2 changed files with 16 additions and 17 deletions
14
C4/Labels.pm
14
C4/Labels.pm
|
@ -362,13 +362,14 @@ sub GetTextWrapCols {
|
||||||
my $string = '0';
|
my $string = '0';
|
||||||
my $strwidth;
|
my $strwidth;
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
|
# my $textlimit = $label_width - ($left_text_margin);
|
||||||
my $textlimit = $label_width - ( 2* $left_text_margin);
|
my $textlimit = $label_width - ( 2* $left_text_margin);
|
||||||
|
|
||||||
while ( $strwidth < $textlimit ) {
|
while ( $strwidth < $textlimit ) {
|
||||||
$count++;
|
|
||||||
$strwidth = prStrWidth( $string, $font, $fontsize );
|
$strwidth = prStrWidth( $string, $font, $fontsize );
|
||||||
$string = $string . '0';
|
$string = $string . '0';
|
||||||
#warn "strwidth:$strwidth, textlimit:$textlimit, count:$count string:$string";
|
#warn "strwidth:$strwidth, textlimit:$textlimit, count:$count string:$string";
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
@ -835,7 +836,7 @@ sub deduplicate_batch {
|
||||||
|
|
||||||
sub DrawSpineText {
|
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 )
|
$text_wrap_cols, $item, $conf_data, $printingtype )
|
||||||
= @_;
|
= @_;
|
||||||
# hack to fix column name mismatch betwen labels_conf.class, and bibitems.classification
|
# hack to fix column name mismatch betwen labels_conf.class, and bibitems.classification
|
||||||
|
@ -845,7 +846,6 @@ sub DrawSpineText {
|
||||||
$Text::Wrap::separator = "\n";
|
$Text::Wrap::separator = "\n";
|
||||||
|
|
||||||
my $str;
|
my $str;
|
||||||
## $item
|
|
||||||
|
|
||||||
my $top_text_margin = ( $fontsize + 3 ); #FIXME: This should be a template parameter and passed in...
|
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 $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 $str_fields = get_text_fields($layout_id, 'codes' );
|
||||||
my @fields = split(/ /, $str_fields);
|
my @fields = split(/ /, $str_fields);
|
||||||
#warn Dumper(@fields);
|
#warn Dumper(@fields);
|
||||||
### @fields
|
|
||||||
|
|
||||||
my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
|
my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
|
||||||
|
my $font = prFont($fontname);
|
||||||
|
|
||||||
# warn Dumper $conf_data;
|
# warn Dumper $conf_data;
|
||||||
#warn Dumper $item;
|
#warn Dumper $item;
|
||||||
|
@ -897,11 +897,11 @@ sub DrawSpineText {
|
||||||
foreach my $str (@strings) {
|
foreach my $str (@strings) {
|
||||||
my $hPos;
|
my $hPos;
|
||||||
if ( $printingtype eq 'BIB' ) { #FIXME: This is a hack and needs to be implimented as a text justification option in the template...
|
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...
|
# some code to try and center each line on the label based on font size and string point width...
|
||||||
my $stringwidth = prStrWidth($str, $font, $fontsize);
|
my $stringwidth = prStrWidth($str, $fontname, $fontsize);
|
||||||
my $whitespace = ( $label_width - ( $stringwidth + (2 * $left_text_margin) ) );
|
my $whitespace = ( $label_width - ( $stringwidth + (2 * $left_text_margin) ) );
|
||||||
$hPos = ( ( $whitespace / 2 ) + $x_pos + $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 {
|
} else {
|
||||||
$hPos = ( $x_pos + $left_text_margin );
|
$hPos = ( $x_pos + $left_text_margin );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
$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;
|
warn "Starting on label #$start_label" if $DEBUG;
|
||||||
my $fontsize = $template->{'fontsize'};
|
|
||||||
my $units = $template->{'units'};
|
my $units = $template->{'units'};
|
||||||
|
|
||||||
warn "UNITS $units";
|
#warn "UNITS $units";
|
||||||
warn "fontsize = $fontsize";
|
#warn "fontsize = $fontsize";
|
||||||
#warn Dumper $template;
|
#warn Dumper $template;
|
||||||
|
|
||||||
my $unitvalue = GetUnitsValue($units);
|
my $unitvalue = GetUnitsValue($units);
|
||||||
|
@ -88,10 +87,10 @@ prFile();
|
||||||
# Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique
|
# 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
|
# They can be abbreviated: TR, TB, TI, TBI, C, CB, CO, CBO, H, HB, HO, HBO
|
||||||
|
|
||||||
my $fontname = $template->{'font'};
|
my $fontsize = $template->{'fontsize'};
|
||||||
my $font = prFont( $fontname );
|
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;
|
#warn $label_cols, $label_rows;
|
||||||
|
|
||||||
|
@ -213,7 +212,7 @@ foreach $item (@resultsloop) {
|
||||||
|
|
||||||
DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width,
|
DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width,
|
||||||
$barcode, $barcodetype );
|
$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 );
|
$left_text_margin, $text_wrap_cols, \$item, \$conf_data );
|
||||||
|
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
|
@ -224,7 +223,7 @@ foreach $item (@resultsloop) {
|
||||||
my $barcode_height = $label_height / 2;
|
my $barcode_height = $label_height / 2;
|
||||||
DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $barcode,
|
DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $barcode,
|
||||||
$barcodetype );
|
$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 );
|
$left_text_margin, $text_wrap_cols, \$item, \$conf_data );
|
||||||
|
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
|
@ -236,7 +235,7 @@ foreach $item (@resultsloop) {
|
||||||
$barcodetype );
|
$barcodetype );
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
|
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 );
|
$left_text_margin, $text_wrap_cols, \$item, \$conf_data );
|
||||||
|
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
|
@ -245,7 +244,7 @@ foreach $item (@resultsloop) {
|
||||||
|
|
||||||
elsif ( $printingtype eq 'BIB' ) {
|
elsif ( $printingtype eq 'BIB' ) {
|
||||||
drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
|
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 );
|
$left_text_margin, $text_wrap_cols, \$item, \$conf_data, $printingtype );
|
||||||
CalcNextLabelPos();
|
CalcNextLabelPos();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue