Bugzilla – Attachment 22142 Details for
Bug 2499
Improvement on text wrapping algorithm needed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
Bug-2499-remove-arbitrary-line-limit-for-label-tex.patch (text/plain), 6.50 KB, created by
Joy Nelson
on 2013-10-21 00:09:53 UTC
(
hide
)
Description:
Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
Filename:
MIME Type:
Creator:
Joy Nelson
Created:
2013-10-21 00:09:53 UTC
Size:
6.50 KB
patch
obsolete
>From 6577845035f911794b14fd07a8651c6aa817fd31 Mon Sep 17 00:00:00 2001 >From: wajasu <matted-34813@mypacks.net> >Date: Tue, 5 Mar 2013 22:49:50 -0600 >Subject: [PATCH] Bug 2499 remove arbitrary line limit for label text lines > >Currently there is a limit of one line per field, and 2 lines in the >case of the 'title' line, that can be written. This patch calculates >the number of lines that are drawable and stop printing lines if >it detects it will overlay the barcode or overrun the label edge. > >This allows one to cram more data in a label. > >An adjustment to the bottom margin below a barcode was made to reduce >a squeeze effect that happens where the top_text_margin gets bigger. >Since no bottom margin is settable, it currently uses the >top_text_margin setting. Now it uses 20% of the top_text_margin to >supply less of a margin, but reduces the chance of text overlay >in a barcode. > >Signed-off-by: Joy Nelson <joy@bywatersolutions.com> >--- > C4/Labels/Label.pm | 23 ++++++++++------------- > 1 files changed, 10 insertions(+), 13 deletions(-) > >diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm >index 5ec9142..b1b41a9 100644 >--- a/C4/Labels/Label.pm >+++ b/C4/Labels/Label.pm >@@ -267,7 +267,7 @@ sub _BIB { > sub _BAR { > my $self = shift; > my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($llx) >- my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly) >+ my $barcode_lly = $self->{'lly'} + ($self->{'top_text_margin'} *.2); # this places the bottom left of the barcode at 20% of the top text margin distance above the bottom of the label ($lly) > my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width > my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height > return 0, 0, 0, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor; >@@ -276,7 +276,7 @@ sub _BAR { > sub _BIBBAR { > my $self = shift; > my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'}) >- my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly) >+ my $barcode_lly = $self->{'lly'} + ($self->{'top_text_margin'} * .2); # this places the bottom left of the barcode at 20% of the top text margin distance above the bottom of the label ($lly) > my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width > my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height > my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.). >@@ -288,7 +288,7 @@ sub _BIBBAR { > sub _BARBIB { > my $self = shift; > my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'}; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'}) >- my $barcode_lly = ($self->{'lly'} + $self->{'height'}) - $self->{'top_text_margin'}; # this places the bottom left of the barcode the top text margin distance below the top of the label ($self->{'lly'}) >+ my $barcode_lly = ($self->{'lly'} + $self->{'height'}) - ($self->{'top_text_margin'} * .2); # this places the bottom left of the barcode at 20% of the top text margin distance below the top of the label ($self->{'lly'}) > my $barcode_width = 0.8 * $self->{'width'}; # this scales the barcode width to 80% of the label width > my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height > my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.). >@@ -450,6 +450,11 @@ sub draw_label_text { > # FIXME - returns all items, so you can't get data from an embedded holdings field. > # TODO - add a GetMarcBiblio1item(bibnum,itemnum) or a GetMarcItem(itemnum). > my $cn_source = ($item->{'cn_source'} ? $item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource')); >+ # calculate how many lines we can write in an area, use line_spacer for height of fontchar >+ my $textarea_height = $self->{'height'} - ( $self->{'top_text_margin'} + ($self->{'top_text_margin'} * 0.5 )) - >+ $self->{'barcode_y_scale_factor'} - $params{'line_spacer'}; >+ my $line_height_sum = 0.0; # accumulator for line height points used >+ > LABEL_FIELDS: # process data for requested fields on current label > for my $field (@$label_fields) { > if ($field->{'code'} eq 'itemtype') { >@@ -494,16 +499,6 @@ sub draw_label_text { > field_data => $field_data > ) }; > >- # If this is a title field, limit to two lines; all others limit to one... FIXME: this is rather arbitrary >- if ($field->{'code'} eq 'title' && scalar(@line) >= 2) { >- while (scalar(@line) > 2) { >- pop @line; >- } >- } else { >- while (scalar(@line) > 1) { >- pop @line; >- } >- } > push(@label_lines, @line); > } > LABEL_LINES: # generate lines of label text for current field >@@ -521,6 +516,8 @@ sub draw_label_text { > else { > $text_llx = ($params{'llx'} + $self->{'left_text_margin'}); > } >+ $line_height_sum = $line_height_sum + $params{'line_spacer'}; # incr by size of a line >+ if ( $line_height_sum > $textarea_height ) { last LABEL_LINES; } # stop drawing if out of bounds > push @label_text, { > text_llx => $text_llx, > text_lly => $text_lly, >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 2499
:
15898
|
15899
|
15900
|
15901
|
15908
| 22142