From d38c4b7f6ee4154429ed29c12f3a2583119e747b Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Thu, 10 Jul 2008 05:16:59 -0400 Subject: [PATCH] Correcting text wrapping on labels Signed-off-by: Joshua Ferraro --- C4/Labels.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/C4/Labels.pm b/C4/Labels.pm index e78df94817..3387a113dc 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -21,7 +21,7 @@ use strict; use vars qw($VERSION @ISA @EXPORT); use PDF::Reuse; -#use Text::Wrap; +use Text::Wrap; use Algorithm::CheckDigits; use C4::Members; use C4::Branch; @@ -1000,13 +1000,11 @@ sub DrawSpineText { } } else { $str =~ s/\/$//g; # Here we will strip out all trailing '/' in fields other than the call number... - if ( length($str) > $text_wrap_cols ) { # wrap lines greater than $text_wrap_cols width... - my $wrap = substr($str, ($text_wrap_cols - length($str)), $text_wrap_cols, ""); - push @strings, $str; - push @strings, $wrap; - } else { - push @strings, $str; - } + # Wrap text lines exceeding $text_wrap_cols length, truncating all text beyond the second line... + $Text::Wrap::columns = $text_wrap_cols; + my @title = split(/\n/ ,wrap('', '', $str)); + pop @title if scalar(@title) > 2; + push(@strings, @title); } # loop for each string line foreach my $str (@strings) { -- 2.39.5