Bugzilla – Attachment 40741 Details for
Bug 14468
Remove warnings when creating Labels
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED OFF] Bug 14468: Remove warnings when creating Labels
SIGNED-OFF-Bug-14468-Remove-warnings-when-creating.patch (text/plain), 4.11 KB, created by
Nick Clemens (kidclamp)
on 2015-07-01 00:10:36 UTC
(
hide
)
Description:
[SIGNED OFF] Bug 14468: Remove warnings when creating Labels
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2015-07-01 00:10:36 UTC
Size:
4.11 KB
patch
obsolete
>From 9818245792e01368924871b3109ea9458e36b653 Mon Sep 17 00:00:00 2001 >From: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Date: Sat, 27 Jun 2015 21:41:01 -0300 >Subject: [PATCH] [SIGNED OFF] Bug 14468: Remove warnings when creating Labels > >This patch removes 2 types of warnings when >creating Labels > >a) Using '0' as filling char is not to the like of prStrWidth >On C4/Creators/Layout.pm > >b) A RM followup from Galen on Bug 8375 to C4/Creators/PDF.pm >makes impossible to find properly a font :( >(http://git.koha-community.org/gitweb/?p=koha.git;a=commit;h=f7ef93e758850e991091e7268b8d1b1453082df4) >on C4/Labels/Label.pm > >To test: >Pre patch >1) Go to Tools > Labels >2) Create a new layout, name ABC, type 'Barcode/Biblio' >3) Create a new batch, add 2 items >4) Export as PDF using the new layout >5) Look at logs, you will find something like > >a) label-create-pdf.pl: Use of uninitialized value $strwidth in numeric lt (<) at /home/bgkriegel/kohaclone/C4/Creators/Layout.pm line 233., referer: http://staffdev.koha-community.org.ar/cgi-bin/koha/labels/label-print.pl >(Only one of this kind) > >b) Two related lines similar to this examples >label-create-pdf.pl: Use of uninitialized value in -e at /home/bgkriegel/kohaclone/C4/Creators/PDF.pm line 226., referer: http://staffdev.koha-community.org.ar/cgi-bin/koha/labels/label-print.pl >label-create-pdf.pl: ERROR in koha-conf.xml -- missing <font type="Ft1">/path/to/font.ttf</font> at /home/bgkriegel/kohaclone/C4/Creators/PDF.pm line 229., referer: http://staffdev.koha-community.org.ar/cgi-bin/koha/labels/label-print.pl >(many many lines x number of items on batch) > >6) Apply the patch >7) Export the same PDF, no more warnings > >8) Bonus 1: change main font to Courier and Helvetica >and check results >9) Bonus 2: check using arabic records > >Many hours to find :( >Easy to fix > >Signed-off-by: Nick Clemens <nick@quecheelibrary.org> >--- > C4/Creators/Layout.pm | 2 +- > C4/Creators/PDF.pm | 12 ++---------- > C4/Labels/Label.pm | 3 +-- > 3 files changed, 4 insertions(+), 13 deletions(-) > >diff --git a/C4/Creators/Layout.pm b/C4/Creators/Layout.pm >index a660ef6..0a72092 100644 >--- a/C4/Creators/Layout.pm >+++ b/C4/Creators/Layout.pm >@@ -228,7 +228,7 @@ sub get_text_wrap_cols { > my $textlimit = $params{'label_width'} - (( 3 * $params{'left_text_margin'} ) || 13.5 ); > > while ($strwidth < $textlimit) { >- $string .= '0'; >+ $string .= '8'; # using '8' as filling char instead of '0' > $col_count++; > $strwidth = C4::Creators::PDF->StrWidth( $string, $self->{'font'}, $self->{'font_size'} ); > } >diff --git a/C4/Creators/PDF.pm b/C4/Creators/PDF.pm >index dd0d3f6..e0c8847 100644 >--- a/C4/Creators/PDF.pm >+++ b/C4/Creators/PDF.pm >@@ -219,16 +219,8 @@ sub StrWidth { > my $self = shift; > my ($string, $font, $fontSize) = @_; > >- # replace font code with path to TTF font file if need be >- my $ttf = C4::Context->config('ttf'); >- if ( $ttf ) { >- my $ttf_path = first { $_->{type} eq $font } @{ $ttf->{font} }; >- if ( -e $ttf_path->{content} ) { >- $font = $ttf_path->{content}; >- } else { >- warn "ERROR in koha-conf.xml -- missing <font type=\"$font\">/path/to/font.ttf</font>"; >- } >- } >+ # replace font code with correct internal font >+ $font = C4::Creators::PDF->Font($font); > > return prStrWidth($string, $font, $fontSize); > } >diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm >index 271c6bc..5aa55ff 100644 >--- a/C4/Labels/Label.pm >+++ b/C4/Labels/Label.pm >@@ -456,9 +456,8 @@ sub draw_label_text { > LABEL_LINES: # generate lines of label text for current field > foreach my $line (@label_lines) { > next LABEL_LINES if $line eq ''; >- my $fontName = C4::Creators::PDF->Font($font); > $line = log2vis( $line ); >- my $string_width = C4::Creators::PDF->StrWidth($line, $fontName, $self->{'font_size'}); >+ my $string_width = C4::Creators::PDF->StrWidth($line, $font, $self->{'font_size'}); > if ($self->{'justify'} eq 'R') { > $text_llx = $params{'llx'} + $self->{'width'} - ($self->{'left_text_margin'} + $string_width); > } >-- >1.9.1
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 14468
:
40699
|
40741
|
41375
|
43882
|
44015
|
44045
|
44063