groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff ChangeLog src/devices/gropdf/gropdf.pl tm...


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog src/devices/gropdf/gropdf.pl tm...
Date: Wed, 15 Feb 2012 13:26:46 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     12/02/15 13:26:46

Modified files:
        .              : ChangeLog 
        src/devices/gropdf: gropdf.pl 
        tmac           : pdf.tmac 

Log message:
        [gropdf] Fixes and omissions.
        
        * src/devices/gropdf/gropdf.pl (<top>, do_u): Add facility to handle
        track kerning (.tkf).
        (do_x, do_p, do_t): If pages are reordered using `pagename' and
        `switchtopage' keep track of outline bookmarks.
        (PutHotSpot): Allow user to control size of hotspot bounding box on
        clickable links by setting PDFHREF.LEADING
        
        * tmac/pdf.tmac (PDFHREF.LEADING): Adjust value.
        (pdf*href): Pass value of PDFHREF.LEADING to gropdf.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1325&r2=1.1326
http://cvs.savannah.gnu.org/viewcvs/groff/src/devices/gropdf/gropdf.pl?cvsroot=groff&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/groff/tmac/pdf.tmac?cvsroot=groff&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1325
retrieving revision 1.1326
diff -u -b -r1.1325 -r1.1326
--- ChangeLog   10 Feb 2012 06:48:26 -0000      1.1325
+++ ChangeLog   15 Feb 2012 13:26:45 -0000      1.1326
@@ -1,3 +1,17 @@
+2012-02-15  Deri James  <address@hidden>
+
+       [gropdf] Fixes and omissions.
+
+       * src/devices/gropdf/gropdf.pl (<top>, do_u): Add facility to handle
+       track kerning (.tkf).
+       (do_x, do_p, do_t): If pages are reordered using `pagename' and
+       `switchtopage' keep track of outline bookmarks.
+       (PutHotSpot): Allow user to control size of hotspot bounding box on
+       clickable links by setting PDFHREF.LEADING
+
+       * tmac/pdf.tmac (PDFHREF.LEADING): Adjust value.
+       (pdf*href): Pass value of PDFHREF.LEADING to gropdf.
+
 2012-02-10  Deri James  <address@hidden>
 
        [gropdf] Fix compatibility issues with pdfmark.

Index: src/devices/gropdf/gropdf.pl
===================================================================
RCS file: /cvsroot/groff/groff/src/devices/gropdf/gropdf.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- src/devices/gropdf/gropdf.pl        14 Aug 2011 14:46:19 -0000      1.4
+++ src/devices/gropdf/gropdf.pl        15 Feb 2012 13:26:46 -0000      1.5
@@ -4,7 +4,7 @@
 #      Deri James      : 4th May 2009
 #
 
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 2012 Free Software Foundation, Inc.
 #      Written by Deri James <address@hidden>
 #
 # This file is part of groff.
@@ -66,6 +66,8 @@
 my $xpos=0;    # Current X position
 my $ypos=0;    # Current Y position
 my $tmxpos=0;
+my $kernadjust=0;
+my $curkern=0;
 my $widtbl;    # Pointer to width table for current font size
 my $origwidtbl; # Pointer to width table
 my $krntbl;    # Pointer to kern table
@@ -84,6 +86,7 @@
 my %incfil;    # Included Files
 my @outlev=([0,undef,0,0]);    # Structure pdfmark /OUT entries
 my address@hidden;
+my $curoutlevno=0;     # Growth point for @curoutlev
 my $Foundry='';
 my $xrev=0;    # Reverse x direction of font
 my $matrixchg=0;
@@ -94,6 +97,7 @@
 my $n_flg=1;
 my $pginsert=-1;    # Growth point for kids array
 my %pgnames;        # 'names' of pages for switchtopage
+my @outlines=();    # State of Bookmark Outlines at end of each page
 
 my %ppsz=(     'ledger'=>[1224,792],
        'legal'=>[612,1008],
@@ -234,6 +238,7 @@
        do_V($lin),next if ($cmd eq 'V');
        do_v($lin),next if ($cmd eq 'v');
        do_t($lin),next if ($cmd eq 't');
+       do_u($lin),next if ($cmd eq 'u');
        do_C($lin),next if ($cmd eq 'C');
        do_c($lin),next if ($cmd eq 'c');
        do_N($lin),next if ($cmd eq 'N');
@@ -547,6 +552,8 @@
     }
     elsif ($xcmd eq 'i')       # Initialise
     {
+       if ($objct == 0)
+       {
        $objct++;
        @address@hidden;
        BuildObj($objct,{'Pages' => BuildObj($objct+1,
@@ -567,6 +574,7 @@
        $pages=$obj[2]->{DATA};
        Put("%PDF-1.4\n\x25\xe2\xe3\xcf\xd3\n");
     }
+    }
     elsif ($xcmd eq 'X')
     {
        # There could be extended args
@@ -695,6 +703,7 @@
                            my $thisoutlev=$curoutlev->[$#{$curoutlev}]->[1];
                            $thisoutlev->[0]=[0,$curoutlev,0,$levsgn];
                            $curoutlev=$thisoutlev;
+                           $curoutlevno=$#{$curoutlev};
                            $thislev++;
                        }
                        elsif ($lev < $thislev)
@@ -709,13 +718,17 @@
                                $curoutlev=$nxtoutlev;
                                $thislev--;
                            }
+
+                           $curoutlevno=$#{$curoutlev};
                        }
 
-                       push(@{$curoutlev},$this);
+#                      push(@{$curoutlev},$this);
+                       splice(@{$curoutlev},++$curoutlevno,0,$this);
                        $curoutlev->[0]->[2]++;
                    }
                    else
                    {
+                       # This code supports old pdfmark.tmac, unused by 
pdf.tmac
                        while ($curoutlev->[0]->[0] == 0 and 
defined($curoutlev->[0]->[1]))
                        {
                            $curoutlev=$curoutlev->[0]->[1];
@@ -856,8 +869,8 @@
            }
            elsif (lc($xprm[1]) eq 'markstart')
            {
-               $mark={'rst' => $xprm[2]/$unitwidth, 'rsb' => 
$xprm[3]/$unitwidth, 'xpos' => $xpos,
-                           'ypos' => $ypos, 'pdfmark' => join(' 
',@xprm[4..$#xprm])};
+               $mark={'rst' => ($xprm[2]+$xprm[4])/$unitwidth, 'rsb' => 
($xprm[3]-$xprm[4])/$unitwidth, 'xpos' => $xpos-($xprm[4]/$unitwidth),
+                           'ypos' => $ypos, 'lead' => $xprm[4]/$unitwidth, 
'pdfmark' => join(' ',@xprm[5..$#xprm])};
            }
            elsif (lc($xprm[1]) eq 'markend')
            {
@@ -899,11 +912,11 @@
                        $ba='before';
                    }
 
-                   if (!defined($ba) or $ba eq '' or $ba eq 'bottom')
+                   if (!defined($ba) or $ba eq '' or $want eq 'bottom')
                    {
                        $pginsert=$#{$pages->{Kids}};
                    }
-                   elsif ($ba eq 'top')
+                   elsif ($want eq 'top')
                    {
                        $pginsert=-1;
                    }
@@ -919,7 +932,8 @@
                            }
                            else
                            {
-
+                               FIND: while (1)
+                               {
                                foreach my $j (0..$#{$pages->{Kids}})
                                {
                                    if ($ref eq $pages->{Kids}->[$j])
@@ -927,22 +941,26 @@
                                        if ($ba eq 'before')
                                        {
                                            $pginsert=$j-1;
-                                           return;
+                                               last FIND;
                                        }
                                        elsif ($ba eq 'after')
                                        {
                                            $pginsert=$j;
-                                           return;
+                                               last FIND;
                                        }
                                        else
                                        {
                                            Msg(0,"Parameter must be 
top|bottom|before|after not '$ba'");
-                                           return;
+                                               last FIND;
                                        }
                                    }
+
                                }
 
                                Msg(0,"Can't find page ref '$ref'");
+                                   last FIND
+
+                               }
                            }
                        }
                        else
@@ -951,6 +969,14 @@
                        }
                    }
 
+                   if ($pginsert < 0)
+                   {
+                       ($curoutlev,$curoutlevno,$thislev)=(address@hidden,0,1);
+                   }
+                   else
+                   {
+                       
($curoutlev,$curoutlevno,$thislev)=(@{$outlines[$pginsert]});
+                   }
                }
            }
        }
@@ -978,7 +1004,7 @@
     my $annotno=BuildObj(++$objct,ParsePDFValue(address@hidden));
     my $annot=$obj[$objct];
     $annot->{DATA}->{Type}='/Annot';
-    
$annot->{DATA}->{Rect}=[$mark->{xpos},$mark->{ypos}-$mark->{rsb},$endx,$mark->{ypos}-$mark->{rst}];
+    
$annot->{DATA}->{Rect}=[$mark->{xpos},$mark->{ypos}-$mark->{rsb},$endx+$mark->{lead},$mark->{ypos}-$mark->{rst}];
     FixRect($annot->{DATA}->{Rect}); # Y origin to ll
     push(@{$cpage->{Annots}},$annotno);
 }
@@ -2155,6 +2181,7 @@
        );
 
     splice(@{$pages->{Kids}},++$pginsert,0,$thispg);
+    splice(@outlines,$pginsert,0,[$curoutlev,$#{$curoutlev}+1,$thislev]);
 
     $objct+=1;
     $cpage=$obj[$cpageno]->{DATA};
@@ -2874,6 +2901,13 @@
     # $nomove = width of char(s) added by 'C', 'N' or 'c'
     # $w-flg  = 'w' seen since last t
 
+    if ($kernadjust != $curkern)
+    {
+       PutLine();
+       $stream.="$kernadjust Tc\n";
+       $curkern=$kernadjust;
+    }
+
     if ($fontchg)
     {
        PutLine();
@@ -2938,6 +2972,16 @@
     }
 }
 
+sub do_u
+{
+    my $par=shift;
+
+    $par=m/([+-]?\d+) (.*)/;
+    $kernadjust=$1/$unitwidth;
+    do_t($2);
+    $kernadjust=0;
+}
+
 sub do_h
 {
     $pendmv+=shift;

Index: tmac/pdf.tmac
===================================================================
RCS file: /cvsroot/groff/groff/tmac/pdf.tmac,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- tmac/pdf.tmac       10 Feb 2012 06:48:29 -0000      1.2
+++ tmac/pdf.tmac       15 Feb 2012 13:26:46 -0000      1.3
@@ -297,7 +297,7 @@
 .\" note that it is defined as a string, so it will adapt to changes
 .\" in the vertical spacing.  Changing it is NOT RECOMMENDED.
 .\"
-.nr PDFHREF.LEADING -1.0p
+.nr PDFHREF.LEADING  2.0p
 .ds PDFHREF.HEIGHT   1.0v
 .\"
 .\" PDF readers generally place a rectangular border around link
@@ -649,7 +649,7 @@
 .   \"
 .   if dPDFHREF.COLOUR .defcolor pdf:href.colour rgb \\*[PDFHREF.COLOUR]
 .   nr pdf:bm.width \\w'\\*[PDFHREF.DESC]'
-.   nop \&\m[\\*[PDFHREF.TEXT.COLOUR]]\X'pdf: markstart \\n[rst] \\n[rsb]  
\\*[pdf:href.link]'\\*[PDFHREF.DESC]\X'pdf: markend'\m[]\c
+.   nop \&\m[\\*[PDFHREF.TEXT.COLOUR]]\X'pdf: markstart \\n[rst] \\n[rsb] 
\\n[PDFHREF.LEADING] \\*[pdf:href.link]'\\*[PDFHREF.DESC]\X'pdf: markend'\m[]\c
 .   \"
 .   \" Clean up the temporary registers and strings, used to
 .   \" compute the "hot-spot" bounds, and format the reference,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]