[Koha-bugs] [Bug 2499] Improvement on text wrapping algorithm needed

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Mar 5 03:10:26 CET 2013


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=2499

--- Comment #4 from Chris Nighswonger <cnighswonger at foundations.edu> ---
I'm not sure what approach you've taken, but here is the problem code:

http://git.koha-community.org/gitweb/?p=koha.git;a=blob;f=C4/Labels/Label.pm;h=760bacfed998674f9b6544bae7a25b0f9d4aa811;hb=HEAD#l433

 433             eval{$Text::Wrap::columns = $self->{'text_wrap_cols'};};
 434             my @line = split(/\n/ ,wrap('', '', $field_data));
 435             # If this is a title field, limit to two lines; all others
limit to one... FIXME: this is rather arbitrary
 436             if ($field->{'code'} eq 'title' && scalar(@line) >= 2) {
 437                 while (scalar(@line) > 2) {
 438                     pop @line;
 439                 }
 440             } else {
 441                 while (scalar(@line) > 1) {
 442                     pop @line;
 443                 }
 444             }
 445             push(@label_lines, @line);
 446         }

As it is it is, well, rather arbitrary.

A little while later we do something much more intelligent to figure line width
in the justification routine:

 450             my $string_width = C4::Creators::PDF->StrWidth($line, $font,
$self->{'font_size'});

Something similar could be done to replace the arbitrary method back at lines
433-446.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list