On Wed 11 Mar 2015 09:36:15 Ellam ByDefault wrote:
> I'm writing a document parser which outputs to groff to be processed with
> gropdf.
> When the parse document contains unicode ellipsis (u+2026), it goes fine
> with few groff fonts, namely Times, Helvetica, Courier.
> But with Palatino and the rest, the document breaks when processed with
> gropdf, emits this message:
> 
> Use of uninitialized value $fld in concatenation (.) or string at
> usr/local/bin/gropdf line 1923, <> line 6838.
> 
> While with grops everything is OK.
> 
> What happens?
> 
> Cheers from Indonesia,
> Ellam ByDefault

It is a bug. The attached patch should update gropdf 1.22.2 to the latest. 
Please can 
you test.

Cheers 

Deri

diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index 9a8288c..8103914 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -467,7 +465,7 @@ sub GetObj
 sub PDFDate
 {
     my $dt=shift;
-    return(sprintf("D:%04d%02d%02d%02d%02d%02d% +02d'00'",$dt->[5]+1900,$dt->[4]+1,$dt->[3],$dt->[2],$dt->[1],$dt->[0],( localtime time() + 3600*( 12 - (gmtime)[2] ) )[2] - 12));
+    return(sprintf("D:%04d%02d%02d%02d%02d%02d%+03d'00'",$dt->[5]+1900,$dt->[4]+1,$dt->[3],$dt->[2],$dt->[1],$dt->[0],( localtime time() + 3600*( 12 - (gmtime)[2] ) )[2] - 12));
 }
 
 sub ToPoints
@@ -711,6 +709,7 @@ sub do_x
 	    {
 		my $pdfmark=$1;
 		$pdfmark=~s((\d{4,6}) u)(sprintf("%.1f",$1/$desc{sizescale}))eg;
+		$pdfmark=~s(\\\[u00(..)\])(chr(hex($1)))eg;
 
 		if ($pdfmark=~m/(.+) \/DOCINFO/)
 		{
@@ -768,7 +767,10 @@ sub do_x
 		}
 		elsif ($pdfmark=~m/(.+) \/OUT/)
 		{
-		    my @xwds=split(' ',"<< $1 >>");
+		    my $t=$1;
+		    $t=~s/\\\) /\\\\\) /g;
+		    $t=~s/\\e/\\\\/g;
+		    my @xwds=split(' ',"<< $t >>");
 		    my $out=ParsePDFValue(\@xwds);
 
 		    my $this=[$out,[]];
@@ -1125,6 +1127,7 @@ sub PutHotSpot
     $l=~s/Color/C/;
     $l=~s/Action/A/;
     $l=~s'/Subtype /URI'/S /URI';
+    $l=~s(\\\[u00(..)\])(chr(hex($1)))eg;
     my @xwds=split(' ',"<< $l >>");
     my $annotno=BuildObj(++$objct,ParsePDFValue(\@xwds));
     my $annot=$obj[$objct];
@@ -1622,7 +1625,7 @@ sub nextwd
 
     return('') if !defined($wd);
 
-    if ($wd=~m/^(.*?)(<<|>>|\[|\])(.*)/)
+    if ($wd=~m/^(.*?)(<<|>>|(?:(?<!\\)\[|\]))(.*)/)
     {
 	if (defined($1) and length($1))
 	{
@@ -2121,14 +2124,31 @@ sub LoadFont
 			{'Type' => '/Font',
 			'Subtype' => '/Type1',
 			'BaseFont' => '/'.$fnt{internalname},
+			'Widths' => $fnt{WID},
+			'FirstChar' => 0,
+			'LastChar' => $lastchr,
 			'Encoding' => BuildObj($objct+1,
 				    {'Type' => '/Encoding',
 				    'Differences' => $fnt{GNO}
 				    }
-				    )
+				    ),
+			'FontDescriptor' => BuildObj($objct+2,
+					{'Type' => '/FontDescriptor',
+					'FontName' => '/'.$fnt{internalname},
+					'Flags' => $t1flags,
+					'FontBBox' => \@fntbbox,
+					'ItalicAngle' => $slant,
+					'Ascent' => $ascent,
+					'Descent' => $fntbbox[1],
+					'CapHeight' => $capheight,
+					'StemV' => 0,
+					'CharSet' => "($charset)",
+					}
+					)
 			}
 			);
-	$objct+=1;
+
+	$objct+=2;
 	$fontlst{$fontno}->{NM}='/F'.$fontno;
 	$pages->{'Resources'}->{'Font'}->{'F'.$fontno}=$fontlst{$fontno}->{OBJ};
 	$fontlst{$fontno}->{FNT}=\%fnt;
@@ -2326,6 +2346,7 @@ sub do_p
     $cpage=$obj[$cpageno]->{DATA};
     $pages->{'Count'}++;
     $stream="q 1 0 0 1 0 0 cm\n$linejoin J\n$linecap j\n";
+    $stream.=$strkcol."\n", $curstrk=$strkcol if $strkcol ne '';
     $mode='g';
     $curfill='';
 #    @mediabox=@defaultmb;
@@ -3028,6 +3049,7 @@ sub TextWid
     my $txt=shift;
     my $w=0;
     my $ck=0;
+    $txt=~s/^\\(\d\d\d)/chr($1)/e;
 
     foreach my $c (split('',$txt))
     {
@@ -3068,7 +3090,7 @@ sub do_t
     $xpos+=($pendmv-$nomove)/$unitwidth;
 
     $stream.="% == '$par'=$wid 'xpos=$xpos\n" if $debug;
-    $par=~s/\\/\\\\/g;
+    $par=~s/\\(?!\d\d\d)/\\\\/g;
     $par=~s/\)/\\)/g;
     $par=~s/\(/\\(/g;
 
@@ -3198,7 +3220,7 @@ sub FindChar
 	my $ch=$fnt->{GNM}->{$chnm};
 	$ch=RemapChr($ch,$fnt,$chnm) if ($ch > 255);
 
-	return(chr($ch),$fnt->{WID}->[$ch]*$cftsz);
+	return(($ch<32)?sprintf("\\%03o",$ch):chr($ch),$fnt->{WID}->[$ch]*$cftsz);
     }
     else
     {
@@ -3222,7 +3244,7 @@ sub RemapChr
     {
 	$fnt->{GNM}->{$chnm}=$unused++;
 	$fnt->{GNO}->[$unused]=$fnt->{GNO}->[$ch+1];
-	$fnt->{WID}->[$unused]=$fnt->{WID}->[$ch+1];
+	$fnt->{WID}->[$unused]=$fnt->{WID}->[$ch];
 	$ch=$unused-1;
 	return($ch);
     }
@@ -3274,3 +3296,11 @@ sub do_n
     @lin=();
     PutHotSpot($xpos) if defined($mark);
 }
+
+
+1;
+########################################################################
+### Emacs settings
+# Local Variables:
+# mode: CPerl
+# End:

Reply via email to