Bugzilla – Attachment 15901 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]
0002-Bug-2499-remove-arbitrary-line-limit-for-label-text
0002-Bug-2499-remove-arbitrary-line-limit-for-label-text-.patch (text/plain), 6.45 KB, created by
wajasu
on 2013-03-06 05:29:54 UTC
(
hide
)
Description:
0002-Bug-2499-remove-arbitrary-line-limit-for-label-text
Filename:
MIME Type:
Creator:
wajasu
Created:
2013-03-06 05:29:54 UTC
Size:
6.45 KB
patch
obsolete
>From 156956d8a5f7199fda4644d77a187b879430b412 Mon Sep 17 00:00:00 2001 >From: wajasu <matted-34813@mypacks.net> >Date: Tue, 5 Mar 2013 22:49:50 -0600 >Subject: [PATCH 2/2] 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. > >--- > C4/Labels/Label.pm | 23 ++++++++++------------- > 1 file changed, 10 insertions(+), 13 deletions(-) > >diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm >index 851ae8f..6c10253 100644 >--- a/C4/Labels/Label.pm >+++ b/C4/Labels/Label.pm >@@ -274,7 +274,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; >@@ -283,7 +283,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.). >@@ -295,7 +295,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.). >@@ -457,6 +457,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') { >@@ -501,16 +506,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 >@@ -528,6 +523,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.8.1.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