Package: libpdf-api2-perl
Version: 2.025-1
Severity: wishlist
Tags: patch upstream
The TrueType, BdFont, CoreFont and Postscript subclasses of
PDF::API2::Resource::Font append '~'.time() to the resource identifiers they
generate. This is unnecessary because the identifier already includes the
result of the pdfkey() function, which gives increasing numbers through a
process lifetime.
Adding time() is in itself not enough to guarantee unique IDs, but only
introduces unreproducible output and poses a slight performance penalty for the
syscall needed to get the current time.
The attached patch removes time() from the resource IDs, which is sufficient to
get reproducible output.
-- dam
-- System Information:
Debian Release: stretch/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.4.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=bg_BG.UTF-8, LC_CTYPE=bg_BG.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages libpdf-api2-perl depends on:
ii libfont-ttf-perl 1.05-1
ii perl 5.22.1-9
libpdf-api2-perl recommends no packages.
libpdf-api2-perl suggests no packages.
-- no debconf information
--- a/lib/PDF/API2/Resource/CIDFont/TrueType.pm
+++ b/lib/PDF/API2/Resource/CIDFont/TrueType.pm
@@ -38,7 +38,7 @@ sub new {
my ($ff,$data)=PDF::API2::Resource::CIDFont::TrueType::FontFile->new($pdf,$file,@opts);
$class = ref $class if ref $class;
- my $self=$class->SUPER::new($pdf,$data->{apiname}.pdfkey().'~'.time());
+ my $self=$class->SUPER::new($pdf,$data->{apiname}.pdfkey());
$pdf->new_obj($self) if(defined($pdf) && !$self->is_obj($pdf));
$self->{' data'}=$data;
@@ -51,7 +51,7 @@ sub new {
$de->{'FontDescriptor'} = $des;
$de->{'Subtype'} = PDFName($self->iscff ? 'CIDFontType0' : 'CIDFontType2');
- ## $de->{'BaseFont'} = PDFName(pdfkey().'+'.($self->fontname).'~'.time());
+ ## $de->{'BaseFont'} = PDFName(pdfkey().'+'.($self->fontname));
$de->{'BaseFont'} = PDFName($self->fontname);
$de->{'DW'} = PDFNum($self->missingwidth);
if($opts{-noembed} != 1)
--- a/lib/PDF/API2/Resource/Font/BdFont.pm
+++ b/lib/PDF/API2/Resource/Font/BdFont.pm
@@ -56,7 +56,7 @@ sub new {
my %opts=@opts;
$class = ref $class if ref $class;
- $self = $class->SUPER::new($pdf, sprintf('%s+Bdf%02i',pdfkey(),++$BmpNum).'~'.time());
+ $self = $class->SUPER::new($pdf, sprintf('%s+Bdf%02i',pdfkey(),++$BmpNum));
$pdf->new_obj($self) unless($self->is_obj($pdf));
# adobe bitmap distribution font
@@ -202,7 +202,7 @@ sub readBDF {
$data->{bbox}{'.notdef'} = [0, 0, 0, 0];
}
- $data->{fontname}=pdfkey().pdfkey().'~'.time();
+ $data->{fontname}=pdfkey();
$data->{apiname}=$data->{fontname};
$data->{flags} = 34;
$data->{fontbbox} = [ split(/\s+/,$data->{FONTBOUNDINGBOX}) ];
--- a/lib/PDF/API2/Resource/Font/CoreFont.pm
+++ b/lib/PDF/API2/Resource/Font/CoreFont.pm
@@ -164,7 +164,7 @@ sub new
#}
$class = ref $class if ref $class;
- $self = $class->SUPER::new($pdf, $data->{apiname}.pdfkey().'~'.time());
+ $self = $class->SUPER::new($pdf, $data->{apiname}.pdfkey());
$pdf->new_obj($self) unless($self->is_obj($pdf));
$self->{' data'}=$data;
$self->{-dokern}=1 if($opts{-dokern});
--- a/lib/PDF/API2/Resource/Font/Postscript.pm
+++ b/lib/PDF/API2/Resource/Font/Postscript.pm
@@ -28,7 +28,7 @@ sub new {
}
$class = ref $class if ref $class;
- $self = $class->SUPER::new($pdf, $data->{apiname}.pdfkey().'~'.time());
+ $self = $class->SUPER::new($pdf, $data->{apiname}.pdfkey());
$pdf->new_obj($self) unless($self->is_obj($pdf));
$self->{' data'}=$data;
@@ -40,7 +40,7 @@ sub new {
$self->{'FontDescriptor'}=$self->descrByData();
if(-f $psfile)
{
- $self->{'BaseFont'} = PDFName(pdfkey().'+'.($self->fontname).'~'.time());
+ $self->{'BaseFont'} = PDFName(pdfkey().'+'.($self->fontname));
my ($l1,$l2,$l3,$stream)=$self->readPFAPFB($psfile);