Bug#658653: libfont-ttf-perl: Multiple uninitialized warnings

Jeffrey Ratcliffe Jeffrey.Ratcliffe at gmail.com
Sat Feb 4 21:59:22 UTC 2012


Package: libfont-ttf-perl
Version: 0.48-1
Severity: minor
Tags: patch

With the following script, multiple warnings are reported:

Use of uninitialized value in numeric gt (>) at /usr/share/perl5/Font/TTF/Glyph.pm line 255.
Use of uninitialized value in pack at /usr/share/perl5/Font/TTF/Cmap.pm line 333.

These would be produced by the test suite, but the testfont.ttf doesn't provoke
them. If DejaVuSans.ttf is used instead of testfont.ttf, then the test suite
produces the above warnings, as well as many more.

The attached two patches fix at least these warnings.

#!/usr/bin/perl -w
use warnings;
use strict;
use PDF::API2;

my $pdf = PDF::API2-> new(-file => 'test.pdf');
my $page = $pdf->page;
my $font = $pdf->ttfont( '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf', -unicodemap => 1 );
my $text = $page->text;
my $size = 12;
$text->font( $font, $size );
$text->translate( 100, 500 );
$text->text( "My text" );
$pdf->save;



-- System Information:
Debian Release: wheezy/sid
  APT prefers oneiric-updates
  APT policy: (500, 'oneiric-updates'), (500, 'oneiric-security'), (500, 'oneiric'), (100, 'oneiric-backports')
Architecture: i386 (i686)

Kernel: Linux 3.0.0-15-generic (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libfont-ttf-perl depends on:
ii  perl                          5.12.4-4   Larry Wall's Practical Extraction 

libfont-ttf-perl recommends no packages.

Versions of packages libfont-ttf-perl suggests:
ii  libxml-parser-perl            2.41-1     Perl module for parsing XML files

-- no debconf information
-------------- next part --------------
--- a/lib/Font/TTF/Glyph.pm
+++ b/lib/Font/TTF/Glyph.pm
@@ -252,7 +252,7 @@
     my ($fh) = $self->{' INFILE'};
     my ($dat);
 
-    return $self if ($self->{' read'} > 0);
+    return $self if (defined($self->{' read'}) and $self->{' read'} > 0);
     $self->{' read'} = 1;
     $fh->seek($self->{' LOC'} + $self->{' BASE'}, 0);
     $fh->read($self->{' DAT'}, $self->{' LEN'});
-------------- next part --------------
--- a/lib/Font/TTF/Cmap.pm
+++ b/lib/Font/TTF/Cmap.pm
@@ -326,11 +326,15 @@
             
         if ($s->{'Format'} == 0)
         {
-            $fh->print(pack("C256", @{$s->{'val'}}{0 .. 255}));
+            for (0 .. 255) {
+              $fh->print(pack("C1", $s->{'val'}{$_})) if (defined $s->{'val'}{$_});
+            }
         } elsif ($s->{'Format'} == 6)
         {
-            $fh->print(pack("n2", $keys[0], $keys[-1] - $keys[0] + 1));
-            $fh->print(pack("n*", @{$s->{'val'}}{$keys[0] .. $keys[-1]}));
+            $fh->print(pack("n2", $keys[0], scalar(@keys)));
+            for (@keys) {
+              $fh->print(pack("n1", $s->{'val'}{$_}));
+            }
         } elsif ($s->{'Format'} == 2)       # Contributed by Huw Rogers
         {
             my ($g, $k, $h, $l, $m, $n);


More information about the pkg-perl-maintainers mailing list