From 1d9d3cbcbe0c157c823fe023b84c65a65d48e6e1 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Fri, 11 Jul 2008 07:40:19 -0400 Subject: [PATCH] Further fixes to Labels.pm including escaping '(' and ')' for the PDF distiller Signed-off-by: Joshua Ferraro --- C4/Labels.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/C4/Labels.pm b/C4/Labels.pm index 3387a113dc..82d4c6b228 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -999,12 +999,23 @@ sub DrawSpineText { push @strings, $str; # if $nowrap == 1 do not wrap or remove segmentation markers... } } else { - $str =~ s/\/$//g; # Here we will strip out all trailing '/' in fields other than the call number... - # Wrap text lines exceeding $text_wrap_cols length, truncating all text beyond the second line... + $str =~ s/\/$//g; # Here we will strip out all trailing '/' in fields other than the call number... + $str =~ s/\(/\\\(/g; # Escape '(' and ')' for the postscript stream... + $str =~ s/\)/\\\)/g; + # Wrap text lines exceeding $text_wrap_cols length... $Text::Wrap::columns = $text_wrap_cols; - my @title = split(/\n/ ,wrap('', '', $str)); - pop @title if scalar(@title) > 2; - push(@strings, @title); + my @line = split(/\n/ ,wrap('', '', $str)); + # If this is a title field, limit to two lines; all others limit to one... + if ($field->{code} eq 'title' && scalar(@line) >= 2) { + while (scalar(@line) > 2) { + pop @line; + } + } else { + while (scalar(@line) > 1) { + pop @line; + } + } + push(@strings, @line); } # loop for each string line foreach my $str (@strings) { -- 2.20.1