groff-commit
[Top][All Lists]
Advanced

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

[Groff-commit] groff ChangeLog doc/groff.texinfo src/devices/g...


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog doc/groff.texinfo src/devices/g...
Date: Sun, 20 May 2012 13:58:10 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     12/05/20 13:58:10

Modified files:
        .              : ChangeLog 
        doc            : groff.texinfo 
        src/devices/gropdf: Makefile.sub gropdf.man gropdf.pl 
        tmac           : pdf.tmac 

Log message:
        * doc/groff.texinfo: Add extra info about `.asciify'.
        Document new gropdf options -u and -s.
        
        * src/devices/gropdf/gropdf.man: Remove references to Type 42 fonts,
        they do not work in PDFs.
        Document new option -s which adds `statistics' line to end of PDF
        file showing number of pages in document.  This has always been the
        default behaviour (to add this line), all other software seems to
        ignore it as intended, but `gs' sometimes complains, so the default
        is now to omit the statistics.
        Document new option -u[cmapfilename] to allow a user ToUnicode CMap
        instead of gropdf's default.  If no `cmapfilename' given then do not
        include any ToUnicode CMap.
        
        * src/devices/gropdf/gropdf.pl <top>: Allow `bundled' flags on
        command line (i.e. -de = -d -e).
        Use $RT_SEP as multi path separator, not hard coded `:'.  Update all
        users.
        New flags -u and -s.
        Once a custom papersize has been set as \X'papersize x,y' make it
        sticky so all following pages use custom size.
        When importing pdf with \X'pdf: pdfpic ...' do not compress objects
        which are already compressed!  This caused problems with PDFs
        created with ImageMagick, now fixed.
        (IsText, PutLine, do_t): The troff `u' command can contain a kerning
        adjustment number, this was not being handled, now fixed.
        (do_c): The troff `c' command was not being handled correctly, now
        fixed.
        (FindChar, RemapChr, do_N): Handle fonts with more than 255 glyphs.
        ($ucmap): Define CMap ToUnicode to convert ligatures
        (fl,fi,ff,ffl,ffi) back to individual characters, useful for
        cut'n'paste and text searching.
        (LoadFont): Handle it.
        (ToPoints, GetPoints): Handle `z' unit.
        (do_x, FixPDFColour, PutHotSpot): Allow Annotation colour to be
        groff colour, i.e. 0-65535 *3, or #rrggbb, or #rrrrbbbbgggg.
        (do_p):The papersize width/length in switch -p were reversed,
        corrected.
        
        * src/devices/gropdf/Makefile.sub (gropdf): Use $RT_SEP.
        Use $fontpath rather than $fontdir (this ensures site-font is
        included in searches).
        
        * tmac/pdf.tmac (PDFBOOKMARK.VIEW, PDFHREF.VIEW, PDFPAGE.Y): Fix
        strings.
        (pdfbookmark): Correct handling of bookmark levels.
        Convert \[em] to hyphen in bookmarks
        Rather use -N than -T for "named" bookmarks (-T already used for "tag"
        in pdfmark.tmac)
        (.pdfclean): New macro which attempts to asciify bookmark text.
        (.pdfpagename): New wrapper macro for \X'pdf: pagename'.
        (.pdfswitchtopage): New wrapper macro for \X'pdf: switchtopage'.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1332&r2=1.1333
http://cvs.savannah.gnu.org/viewcvs/groff/doc/groff.texinfo?cvsroot=groff&r1=1.309&r2=1.310
http://cvs.savannah.gnu.org/viewcvs/groff/src/devices/gropdf/Makefile.sub?cvsroot=groff&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/groff/src/devices/gropdf/gropdf.man?cvsroot=groff&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/groff/src/devices/gropdf/gropdf.pl?cvsroot=groff&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/groff/tmac/pdf.tmac?cvsroot=groff&r1=1.3&r2=1.4

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1332
retrieving revision 1.1333
diff -u -b -r1.1332 -r1.1333
--- ChangeLog   10 Mar 2012 09:16:01 -0000      1.1332
+++ ChangeLog   20 May 2012 13:58:09 -0000      1.1333
@@ -1,3 +1,58 @@
+2012-05-20  Deri James  <address@hidden>
+
+       * doc/groff.texinfo: Add extra info about `.asciify'.
+       Document new gropdf options -u and -s.
+
+       * src/devices/gropdf/gropdf.man: Remove references to Type 42 fonts,
+       they do not work in PDFs.
+       Document new option -s which adds `statistics' line to end of PDF
+       file showing number of pages in document.  This has always been the
+       default behaviour (to add this line), all other software seems to
+       ignore it as intended, but `gs' sometimes complains, so the default
+       is now to omit the statistics.
+       Document new option -u[cmapfilename] to allow a user ToUnicode CMap
+       instead of gropdf's default.  If no `cmapfilename' given then do not
+       include any ToUnicode CMap.
+
+       * src/devices/gropdf/gropdf.pl <top>: Allow `bundled' flags on
+       command line (i.e. -de = -d -e).
+       Use $RT_SEP as multi path separator, not hard coded `:'.  Update all
+       users.
+       New flags -u and -s.
+       Once a custom papersize has been set as \X'papersize x,y' make it
+       sticky so all following pages use custom size.
+       When importing pdf with \X'pdf: pdfpic ...' do not compress objects
+       which are already compressed!  This caused problems with PDFs
+       created with ImageMagick, now fixed.
+       (IsText, PutLine, do_t): The troff `u' command can contain a kerning
+       adjustment number, this was not being handled, now fixed.
+       (do_c): The troff `c' command was not being handled correctly, now
+       fixed.
+       (FindChar, RemapChr, do_N): Handle fonts with more than 255 glyphs.
+       ($ucmap): Define CMap ToUnicode to convert ligatures
+       (fl,fi,ff,ffl,ffi) back to individual characters, useful for
+       cut'n'paste and text searching.
+       (LoadFont): Handle it.
+       (ToPoints, GetPoints): Handle `z' unit.
+       (do_x, FixPDFColour, PutHotSpot): Allow Annotation colour to be
+       groff colour, i.e. 0-65535 *3, or #rrggbb, or #rrrrbbbbgggg.
+       (do_p):The papersize width/length in switch -p were reversed,
+       corrected.
+
+       * src/devices/gropdf/Makefile.sub (gropdf): Use $RT_SEP.
+       Use $fontpath rather than $fontdir (this ensures site-font is
+       included in searches).
+
+       * tmac/pdf.tmac (PDFBOOKMARK.VIEW, PDFHREF.VIEW, PDFPAGE.Y): Fix
+       strings.
+       (pdfbookmark): Correct handling of bookmark levels.
+       Convert \[em] to hyphen in bookmarks
+       Rather use -N than -T for "named" bookmarks (-T already used for "tag"
+       in pdfmark.tmac)
+       (.pdfclean): New macro which attempts to asciify bookmark text.
+       (.pdfpagename): New wrapper macro for \X'pdf: pagename'.
+       (.pdfswitchtopage): New wrapper macro for \X'pdf: switchtopage'.
+
 2012-03-10  Werner LEMBERG  <address@hidden>
 
        Fix compiler warnings.

Index: doc/groff.texinfo
===================================================================
RCS file: /cvsroot/groff/groff/doc/groff.texinfo,v
retrieving revision 1.309
retrieving revision 1.310
diff -u -b -r1.309 -r1.310
--- doc/groff.texinfo   8 Dec 2011 06:44:19 -0000       1.309
+++ doc/groff.texinfo   20 May 2012 13:58:10 -0000      1.310
@@ -26,7 +26,7 @@
 @copying
 This manual documents GNU @code{troff} version 1.21.
 
-Copyright @copyright{} 1994-2011 Free Software Foundation, Inc.
+Copyright @copyright{} 1994-2012 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -472,7 +472,7 @@
 @title groff
 @subtitle The GNU implementation of @code{troff}
 @subtitle Edition 1.21
address@hidden Winter 2010
address@hidden Spring 2012
 @author by Trent address@hidden
 @author and Werner Lemberg (@email{bug-groff@@gnu.org})
 
@@ -13012,6 +13012,10 @@
 .x
 @endExample
 
+Note that @code{asciify} cannot return all items in a diversion back
+to their source equivalent, nodes such as @code{\N[...]} will still
+remain as nodes, so the result cannot be guaranteed to be a pure string.
+
 @xref{Copy-in Mode}.
 @endDefreq
 
@@ -15198,6 +15202,18 @@
 
 @item -v
 Print the version number.
+
address@hidden -s
+Append a comment line to end of PDF showing statistics, i.e. number of
+pages in document.  Ghostscript's @cite{ps2pdf(1)} complains about this
+line if it is included, but works anyway.
+
address@hidden address@hidden
address@hidden normally includes a ToUnicode CMap with any font created
+using @file{text.enc} as the encoding file, this makes it easier to
+search for words which contain ligatures.  You can include your own CMap
+by specifying a @var{filename} or have no CMap at all by omitting the
address@hidden
 @end table
 
 @c ---------------------------------------------------------------------

Index: src/devices/gropdf/Makefile.sub
===================================================================
RCS file: /cvsroot/groff/groff/src/devices/gropdf/Makefile.sub,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- src/devices/gropdf/Makefile.sub     26 Jul 2011 17:11:11 -0000      1.1
+++ src/devices/gropdf/Makefile.sub     20 May 2012 13:58:10 -0000      1.2
@@ -38,7 +38,8 @@
        sed -f $(SH_DEPS_SED_SCRIPT) \
            -e "s|@VERSION@|$(version)$(revision)|" \
            -e "s|@PERLPATH@|$(PERLPATH)|" \
-           -e "s|@GROFF_FONT_DIR@|$(fontdir)|" $(srcdir)/gropdf.pl >$@
+           -e "s|@GROFF_FONT_DIR@|$(fontpath)|" \
+           -e "s|@RT_SEP@|$(RT_SEP)|" $(srcdir)/gropdf.pl >$@
        chmod +x $@
 
 install_data:

Index: src/devices/gropdf/gropdf.man
===================================================================
RCS file: /cvsroot/groff/groff/src/devices/gropdf/gropdf.man,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/devices/gropdf/gropdf.man       10 Aug 2011 18:23:01 -0000      1.2
+++ src/devices/gropdf/gropdf.man       20 May 2012 13:58:10 -0000      1.3
@@ -1,5 +1,5 @@
 .ig
-Copyright (C) 2011
+Copyright (C) 2011-2012
   Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
@@ -43,12 +43,13 @@
 .SH SYNOPSIS
 .
 .SY gropdf
-.OP \-delv
+.OP \-delvs
 .OP \-F dir
 \#.OP \-I dir
 .OP \-p papersize
 \#.OP \-w n
 .OP \-y foundry
+.OP \-u [cmapfile]
 .RI [ files
 .IR .\|.\|. ]
 .YS
@@ -188,7 +189,30 @@
 .
 .TP
 .B \-e
-Forces gropdf to embed ALL fonts (even the 14 base PDF fonts). 
+Forces
+.B gropdf
+to embed ALL fonts (even the 14 base PDF fonts).
+.
+.TP
+.B \-s
+Append a comment line to end of PDF showing statistics,
+i.e. number of pages in document.
+Ghostscript's
+.B ps2pdf
+complains about this line if it is included, but works anyway.
+.
+.TP
+.B \-u
+.TQ
+.BI \-u cmapfilename
+.B Gropdf
+normally includes a ToUnicode CMap with any font created using
+.B text.enc
+as the encoding file,
+this makes it easier to search for words which contain ligatures.
+You can include your own CMap by specifying a
+.I cmapfilename
+or have no CMap at all by omitting the argument.
 .
 .
 .SH USAGE
@@ -804,52 +828,7 @@
 .SS TrueType and other font formats
 .
 .B gropdf
-does not support TrueType fonts natively within the PDF files it generates
-(but does support any fonts if they are in an imported PDF).
-.
-However, TrueType fonts can be used with
-.B gropdf
-if converted first to
-.B Type\~42
-format, a special PostScript wrapper equivalent to the PFA format mentioned
-in
-.BR \%pfbtops (@MAN1EXT@).
-.
-There are several different methods to generate a Type\~42
-wrapper and most of them involve the use of a PostScript
-interpreter such as Ghostscript \[en] see
-.BR gs (1).
-.
-.LP
-Yet, the easiest method involves the use of the application
-.BR ttftot42 (1).
-.
-This program uses
-.BR freetype (3)
-(version 1.3.1) to generate Type\~42
-font wrappers and well-formed AFM files that can be fed to the
-.BR \%afmtodit (@MAN1EXT@)
-script to create appropriate metric files.
-.
-The resulting font wrappers should be added to groff's
-.B download
-file.
-.
-.B ttftot42
-source code can be downloaded from
-.UR ftp://\:www.giga.or.at/\:pub/\:nih/\:ttftot42/
-ftp://\:www.giga.or.at/\:pub/\:nih/\:ttftot42/
-.UE .
-.
-.LP
-Another solution for creating Type\~42 wrappers is to use FontForge,
-available from
-.UR http://\:fontforge.sf.net
-http://\:fontforge.sf.net
-.UE .
-.
-This font editor can convert most outline font formats.
-.
+does not support any other fonts except Adobe Type 1 (PFA or PFB).
 .
 .SH FONT INSTALLATION
 .
@@ -865,8 +844,8 @@
 .LI
 Convert your font to something groff understands.
 .
-This is either a PostScript Type\~1 font in either PFA or PFB format or a
-PostScript Type\~42 font, together with an AFM file.
+This is either a PostScript Type\~1 font in either PFA or PFB,
+together with an AFM file.
 .
 .IP
 The very first line in a PFA/PFB file contains this:
@@ -880,29 +859,6 @@
 A PFB file has this also in the first line, but the string is
 preceded with some binary bytes.
 .
-.IP
-The very first characters in a Type\~42 font file look like this:
-.
-.RS
-.IP
-.B %!PS-TrueTypeFont
-.RE
-.
-.IP
-This is a wrapper format for TrueType fonts.
-.
-Old PS printers might not support it (this is, they don't have a
-built-in TrueType font interpreter).
-.
-.IP
-For TrueType fonts, try
-.B ttftot42
-or
-.BR fontforge .
-For all other font formats use
-.B fontforge
-which can convert most outline font formats.
-.
 .LI
 Convert the AFM file to a groff font description file with the
 .BR \%afmtodit (@MAN1EXT@)

Index: src/devices/gropdf/gropdf.pl
===================================================================
RCS file: /cvsroot/groff/groff/src/devices/gropdf/gropdf.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- src/devices/gropdf/gropdf.pl        15 Feb 2012 13:26:46 -0000      1.5
+++ src/devices/gropdf/gropdf.pl        20 May 2012 13:58:10 -0000      1.6
@@ -23,13 +23,14 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 use strict;
-use Getopt::Long;
+use Getopt::Long qw(:config bundling);
 use Compress::Zlib;
 
 my %cfg;
 
 $cfg{GROFF_VERSION}='@VERSION@';
 $cfg{GROFF_FONT_PATH}='@GROFF_FONT_DIR@';
+$cfg{RT_SEP}='@RT_SEP@';
 binmode(STDOUT);
 
 my @obj;       # Array of PDF objects
@@ -98,6 +99,8 @@
 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 $custompaper=0;  # Has there been an X papersize
+my $textenccmap=''; # CMap for groff text.enc encoding
 
 my %ppsz=(     'ledger'=>[1224,792],
        'legal'=>[612,1008],
@@ -128,6 +131,29 @@
        'c5'=>[459,649],
        'c6'=>[323,459] );
 
+my $ucmap=<<'EOF';
+/CIDInit /ProcSet findresource begin
+12 dict begin
+begincmap
+/CIDSystemInfo
+<< /Registry (Adobe)
+/Ordering (UCS)
+/Supplement 0
+>> def
+/CMapName /Adobe-Identity-UCS def
+/CMapType 2 def
+1 begincodespacerange
+<0000> <FFFF>
+endcodespacerange
+2 beginbfrange
+<008b> <008f> [<00660066> <00660069> <0066006c> <006600660069> <00660066006C>]
+<00ad> <00ad> <002d>
+endbfrange
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+EOF
 
 my $fd;
 my $frot;
@@ -135,10 +161,12 @@
 my $embedall=0;
 my $debug=0;
 my $version=0;
+my $stats=0;
+my $unicodemap;
 
 #Load_Config();
 
-GetOptions("F=s" => \$fd, 'l' => \$frot, 'p=s' => \$fpsz, 'd!' => \$debug, 'v' 
=> \$version, 'e' => \$embedall, 'y=s' => \$Foundry);
+GetOptions("F=s" => \$fd, 'l' => \$frot, 'p=s' => \$fpsz, 'd!' => \$debug, 'v' 
=> \$version, 'e' => \$embedall, 'y=s' => \$Foundry, 's' => \$stats, 'u:s' => 
\$unicodemap);
 
 if ($version)
 {
@@ -146,11 +174,30 @@
     exit;
 }
 
+if (defined($unicodemap))
+{
+    if ($unicodemap eq '')
+    {
+       $ucmap='';
+    }
+    elsif (-r $unicodemap)
+    {
+       local $/;
+       open(F,"<$unicodemap") or die "gropdf: Failed to open '$unicodemap'";
+       ($ucmap)=(<F>);
+       close(F);
+    }
+    else
+    {
+       Msg(0,"Failed to find '$unicodemap' - ignoring");
+    }
+}
+
 # Search for 'font directory': paths in -f opt, shell var GROFF_FONT_PATH, 
default paths
 
 my $fontdir=$cfg{GROFF_FONT_PATH};
-$fontdir=$ENV{GROFF_FONT_PATH}.':'.$fontdir if exists($ENV{GROFF_FONT_PATH});
-$fontdir=$fd.':'.$fontdir if defined($fd);
+$fontdir=$ENV{GROFF_FONT_PATH}.$cfg{RT_SEP}.$fontdir if 
exists($ENV{GROFF_FONT_PATH});
+$fontdir=$fd.$cfg{RT_SEP}.$fontdir if defined($fd);
 
 $rot=90 if $frot;
 $matrix="0 1 -1 0" if $frot;
@@ -267,6 +314,19 @@
 
 PutObj($objct);
 
+foreach my $fontno (keys %fontlst)
+{
+    my $o=$fontlst{$fontno}->{FNT};
+    my $p=GetObj($fontlst{$fontno}->{OBJ});
+
+    if (exists($p->{LastChar}) and $p->{LastChar} > 255)
+    {
+       $p->{LastChar} = 255;
+       splice(@{$o->{GNO}},256);
+       splice(@{$o->{WID}},256);
+    }
+}
+
 foreach my $o (3..$objct)
 {
     PutObj($o) if (!exists($obj[$o]->{XREF}));
@@ -287,7 +347,8 @@
     printf("%010d 00000 n \n",$xr->{XREF});
 }
 
-print "trailer\n<<\n/Info $info\n/Root 1 0 R\n/Size 
$objct\n>>\nstartxref\n$fct\n\%\%EOF\n\% Pages=$pages->{Count}\n";
+print "trailer\n<<\n/Info $info\n/Root 1 0 R\n/Size 
$objct\n>>\nstartxref\n$fct\n\%\%EOF\n";
+print "\% Pages=$pages->{Count}\n" if $stats;
 
 
 sub MakeMatrix
@@ -431,6 +492,10 @@
     {
        return($num*6);
     }
+    elsif ($unit eq 'z')
+    {
+       return($num/$unitwidth);
+    }
     else
     {
        Msg(1,"Unknown scaling factor '$unit'");
@@ -488,7 +553,7 @@
        return if -r "$fnm" and open($$f,"<$fnm");
     }
 
-    my (@dirs)=split(':',$dirs);
+    my (@dirs)=split($cfg{RT_SEP},$dirs);
 
     foreach my $dir (@dirs)
     {
@@ -683,6 +748,7 @@
                    my $annot=$obj[$objct];
                    $annot->{DATA}->{Type}='/Annot';
                    FixRect($annot->{DATA}->{Rect}); # Y origin to ll
+                   FixPDFColour($annot->{DATA});
                    push(@{$cpage->{Annots}},$annotno);
                }
                elsif ($pdfmark=~m/(.+) \/OUT/)
@@ -988,11 +1054,54 @@
            @mediabox=(0,0,$px,$py);
            my @address@hidden;
            $matrixchg=1;
+           $custompaper=1;
            $cpage->address@hidden;
        }
     }
 }
 
+sub FixPDFColour
+{
+    my $o=shift;
+    my $a=$o->{C};
+    my @r=();
+    my $c=$a->[0];
+
+    if ($#{$a}==3)
+    {
+       if ($c > 1)
+       {
+           foreach my $j (0..2)
+           {
+               push(@r,sprintf("%1.3f",$a->[$j]/0xffff));
+           }
+
+           $o->address@hidden;
+       }
+    }
+    elsif (substr($c,0,1) eq '#')
+    {
+       if (length($c) == 7)
+       {
+           foreach my $j (0..2)
+           {
+               push(@r,sprintf("%1.3f",hex(substr($c,$j*2+1,2))/0xff));
+           }
+
+           $o->address@hidden;
+       }
+       elsif (length($c) == 14)
+       {
+           foreach my $j (0..2)
+           {
+               push(@r,sprintf("%1.3f",hex(substr($c,$j*4+2,4))/0xffff));
+           }
+
+           $o->address@hidden;
+       }
+    }
+}
+
 sub PutHotSpot
 {
     my $endx=shift;
@@ -1005,6 +1114,7 @@
     my $annot=$obj[$objct];
     $annot->{DATA}->{Type}='/Annot';
     
$annot->{DATA}->{Rect}=[$mark->{xpos},$mark->{ypos}-$mark->{rsb},$endx+$mark->{lead},$mark->{ypos}-$mark->{rst}];
+    FixPDFColour($annot->{DATA});
     FixRect($annot->{DATA}->{Rect}); # Y origin to ll
     push(@{$cpage->{Annots}},$annotno);
 }
@@ -1029,7 +1139,7 @@
 {
     my $val=shift;
 
-    $val=ToPoints($1,$2) if ($val=~m/(-?[\d.]+)([cipn])/);
+    $val=ToPoints($1,$2) if ($val=~m/(-?[\d.]+)([cipnz])/);
 
     return $val;
 }
@@ -1762,7 +1872,7 @@
     $obj[$ono]->{XREF}=$fct;
     if (exists($obj[$ono]->{STREAM}))
     {
-       if (!$debug)
+       if (!$debug && !exists($obj[$ono]->{DATA}->{'Filter'}))
        {
            $obj[$ono]->{STREAM}=Compress::Zlib::compress($obj[$ono]->{STREAM});
            $obj[$ono]->{DATA}->{'Filter'}=['/FlateDecode'];
@@ -1899,7 +2009,7 @@
            }
 
            $r[0]='u0020' if $r[3] == 32;
-           next if $r[3] >255;
+#          next if $r[3] >255;
            $fnt{GNM}->{$r[0]}=$r[3];
            $fnt{GNO}->[$r[3]]='/'.$r[4];
            $fnt{WID}->[$r[3]]=$p[0];
@@ -2007,10 +2117,21 @@
        $fontlst{$fontno}->{FNT}=\%fnt;
     }
 
-    PutObj($fno);
-    PutObj($fno+1);
-    PutObj($fno+2) if defined($obj[$fno+2]);
-    PutObj($fno+3) if defined($obj[$fno+3]);
+    if (defined($fnt{encoding}) and $fnt{encoding} eq 'text.enc' and $ucmap ne 
'')
+    {
+       if ($textenccmap eq '')
+       {
+           $textenccmap = BuildObj($objct+1,{});
+           $objct++;
+           $obj[$objct]->{STREAM}=$ucmap;
+       }
+       $obj[$fno]->{DATA}->{'ToUnicode'}=$textenccmap;
+    }
+
+#     PutObj($fno);
+#     PutObj($fno+1);
+#     PutObj($fno+2) if defined($obj[$fno+2]);
+#     PutObj($fno+3) if defined($obj[$fno+3]);
 }
 
 sub GetType1
@@ -2164,6 +2285,7 @@
 
     if ($cpageno > 0)
     {
+       $cpage->address@hidden if $custompaper;
        PutObj($cpageno);
        OutStream($cpageno+1);
     }
@@ -2189,7 +2311,7 @@
     $stream="q 1 0 0 1 0 0 cm\n";
     $mode='g';
     $curfill='';
-    @address@hidden;
+#    @address@hidden;
 }
 
 sub do_f
@@ -2248,6 +2370,7 @@
            $whtsz=$fontlst{$cft}->{FNT}->{spacewidth}*$cftsz;
            $stream.="/F$cft $cftsz Tf\n";
        }
+       $stream.="$curkern Tc\n";
     }
 
     if ($poschg or $matrixchg)
@@ -2256,6 +2379,7 @@
        $stream.="$matrix ".PutXY($xpos,$ypos)." Tm\n", $poschg=0;
        $tmxpos=$xpos;
        $matrixchg=0;
+       $stream.="$curkern Tc\n";
     }
 
     if ($fontchg)
@@ -2768,8 +2892,16 @@
     #                          $wt+=$whtsz/$cftsz;
     #                  }
 
-               $stream.=sprintf( "%.3f Tw ",-($whtsz+$wt*$cftsz)/$unitwidth );
+               $stream.=sprintf( "%.3f Tw 
",-($whtsz+$wt*$cftsz)/$unitwidth-$curkern );
+               if (!defined($lin[0]->[0]) and defined($lin[0]->[1]))
+               {
+                   $stream.="[ $lin[0]->[1] (";
+                   shift @lin;
+               }
+               else
+               {
                $stream.="[(";
+               }
 
                foreach my $wd (@lin)
                {
@@ -2787,6 +2919,7 @@
                    }
                    else
                    {
+                       $wwt=sprintf("%.3f",$wwt);
                        $stream.="$wd->[0]) $wwt (" if defined($wd->[0]);
                    }
                }
@@ -2936,11 +3069,13 @@
        PutLine(0) if $#lin > -1;
        MakeMatrix(1);
        $stream.="$matrix ".PutXY($xpos,$ypos)." Tm\n", $poschg=0;
+       $stream.="$curkern Tc\n";
        $stream.="0 Tw ";
        $stream.="($par) Tj\n";
        MakeMatrix();
        $stream.="$matrix ".PutXY($xpos,$ypos)." Tm\n", $poschg=0;
        $matrixchg=0;
+       $stream.="$curkern Tc\n";
        return;
     }
 
@@ -3021,11 +3156,14 @@
 sub FindChar
 {
     my $chnm=shift;
+    my $fnt=$fontlst{$cft}->{FNT};
 
-    if (exists($fontlst{$cft}->{FNT}->{GNM}->{$chnm}))
+    if (exists($fnt->{GNM}->{$chnm}))
     {
-       my $ch=$fontlst{$cft}->{FNT}->{GNM}->{$chnm};
-       return(chr($ch),$fontlst{$cft}->{FNT}->{WID}->[$ch]*$cftsz);
+       my $ch=$fnt->{GNM}->{$chnm};
+       $ch=RemapChr($ch,$fnt,$chnm) if ($ch > 255);
+
+       return(chr($ch),$fnt->{WID}->[$ch]*$cftsz);
     }
     else
     {
@@ -3033,6 +3171,33 @@
     }
 }
 
+sub RemapChr
+{
+    my $ch=shift;
+    my $fnt=shift;
+    my $chnm=shift;
+    my $unused=0;
+
+    foreach my $un (2..$#{$fnt->{GNO}})
+    {
+       $unused=$un,last if $fnt->{GNO}->[$un] eq '/.notdef';
+    }
+
+    if (--$unused <= 255)
+    {
+       $fnt->{GNM}->{$chnm}=$unused++;
+       $fnt->{GNO}->[$unused]=$fnt->{GNO}->[$ch+1];
+       $fnt->{WID}->[$unused]=$fnt->{WID}->[$ch+1];
+       $ch=$unused-1;
+       return($ch);
+    }
+    else
+    {
+       Msg(0,"Too many glyphs used in font '$cft'");
+       return(32);
+    }
+}
+
 sub do_c
 {
     my $par=shift;
@@ -3040,7 +3205,7 @@
     push(@ahead,substr($par,1));
     $par=substr($par,0,1);
     my $ch=ord($par);
-    do_t($ch);
+    do_N($ch);
     $nomove=$fontlst{$cft}->{FNT}->{WID}->[$ch]*$cftsz;
 }
 
@@ -3048,6 +3213,19 @@
 {
     my $par=shift;
 
+    if ($par > 255)
+    {
+       my $fnt=$fontlst{$cft}->{FNT};
+       my $chnm='';
+
+       foreach my $c (keys %{$fnt->{GNM}})
+       {
+           $chnm=$c,last if $fnt->{GNM}->{$c} == $par;
+       }
+
+       $par=RemapChr($par,$fnt,$chnm);
+    }
+
     do_t(chr($par));
     $nomove=$fontlst{$cft}->{FNT}->{WID}->[$par]*$cftsz;
 }

Index: tmac/pdf.tmac
===================================================================
RCS file: /cvsroot/groff/groff/tmac/pdf.tmac,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- tmac/pdf.tmac       15 Feb 2012 13:26:46 -0000      1.3
+++ tmac/pdf.tmac       20 May 2012 13:58:10 -0000      1.4
@@ -144,7 +144,7 @@
 .\" the page width to the viewing window, with the bookmarked entry
 .\" located at the top of the viewable area.
 .\"
-.ds PDFBOOKMARK.VIEW /FitH -\\n[PDFPAGE.Y] u
+.ds PDFBOOKMARK.VIEW /FitH \\n[PDFPAGE.Y] u
 .\"
 .\" "PDFOUTLINE.FOLDLEVEL" controls how the document outline will be
 .\" displayed.  It is a number, defining the maximum heading level
@@ -189,7 +189,7 @@
 .   \"
 .      nr pdf:bm.lev 0+\\$1
 .      if \\n[pdf:bm.lev]==0 .nr pdf:bm.lev 1
-.      if \\n[pdf:bm.lev]>\\n[PDFOUTLINE.FOLDLEVEL] .nr pdf:bm.lev 
\\n[pdf:bm.lev]*-1
+.      if \\n[pdf:bm.lev]-1==\\n[PDFOUTLINE.FOLDLEVEL] .nr pdf:bm.lev 
\\n[pdf:bm.lev]*-1
 .      nr pdf:bm.abslev 0+\\n[pdf:bm.lev]
 .      if \\n[pdf:bm.lev]<0 .nr pdf:bm.abslev 0+\\n[pdf:bm.abslev]*-1
 .      if \\n[pdf:bm.abslev]>\\n[pdf:bm.nl] .nr pdf:bm.nl \\n[pdf:bm.nl]+1
@@ -213,18 +213,24 @@
 .      pdf:href.sety
 .         ds pdf:cleaned \\$*
 .         ev pdfcln
+.         tr \[em]-
 .         nf
 .         box pdf:clean
 .         nop \\$*
-.         sp -1
+.         fl
 .         box
+.         chop pdf:clean
 .         asciify pdf:clean
+.         length pdf:clean:len \\*[pdf:clean]
 .         ds pdf:cleaned \\*[pdf:clean]
+.         rm pdf:clean
 .         ev
+.         tr \[em]\[em]
 .      ds pdf:look(\\*[PDFBOOKMARK.NAME]) \\*[pdf:cleaned]
 .      if dPDF.EXPORT .tm .ds pdf:look(\\*[PDFBOOKMARK.NAME]) \\*[pdf:cleaned]
 .      pdfmark /Dest /\\*[PDFBOOKMARK.NAME] /View [\\*[PDFBOOKMARK.VIEW]] /DEST
-.      pdfmark /Dest /\\*[PDFBOOKMARK.NAME] /Title (\\*[pdf:cleaned]) /Level 
\\n[pdf:bm.lev] /OUT
+.      nop \!x X ps:exec [/Dest /\\*[PDFBOOKMARK.NAME] /Title 
(\\*[pdf:cleaned]) /Level \\n[pdf:bm.lev] /OUT pdfmark
+.\".      pdfmark /Dest /\\*[PDFBOOKMARK.NAME] /Title "(\\*[pdf:cleaned])" 
/Level \\n[pdf:bm.lev] /OUT
 .      pdf:href.options.clear
 .      rr PDFPAGE.Y
 .      rm pdf:cleaned
@@ -240,6 +246,25 @@
 .   nop \!.pdfbookmark \\$@
 .   \}
 ..
+.
+.de pdfclean
+.  ie '\\n(.z'' \{\
+.         ds pdfcleaned \\$*
+.         ev pdfcln
+.         tr \[em]-
+.         nf
+.         box pdf:clean
+.         nop \\*[\\*[pdfcleaned]]
+.         fl
+.         box
+.         chop pdf:clean
+.         asciify pdf:clean
+.         ev
+.         ds \\*[pdfcleaned] "\\*[pdf:clean]
+.         rm pdf:clean
+.         tr \[em]\[em]
+.  el .nop \!.pdfclean \\$@
+..
 .\"
 .\" =============================================================
 .\" Module PDFHREF: Create Hypertext References in a PDF Document
@@ -248,7 +273,7 @@
 .\" "PDFHREF.VIEW" controls how the document will be displayed,
 .\" when the user follows a link to a named reference.
 .\"
-.ds PDFHREF.VIEW     /FitH -\\n[PDFPAGE.Y] u
+.ds PDFHREF.VIEW     /FitH \\n[PDFPAGE.Y] u
 .\"
 .\" This default setting will fit the page width to the viewing
 .\" window, with the bookmarked entry located close to the top
@@ -278,7 +303,7 @@
 .\" in groff's basic units; don't forget to append grops' "u"
 .\" conversion operator, when writing the pdfmark!
 .\"
-.nr PDFPAGE.Y \\n(nl-\\n[PDFHREF.VIEW.LEADING]
+.nr PDFPAGE.Y (\\n[PDFHREF.VIEW.LEADING]-\\n(nl)
 ..
 .\" When we create a link "hot-spot" ...
 .\" "PDFHREF.LEADING" sets the distance above the top of the glyph
@@ -647,7 +672,7 @@
 .   \" limits of its bounding box(es), as the before and after output
 .   \" text positions.
 .   \"
-.   if dPDFHREF.COLOUR .defcolor pdf:href.colour rgb \\*[PDFHREF.COLOUR]
+\#.   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] 
\\n[PDFHREF.LEADING] \\*[pdf:href.link]'\\*[PDFHREF.DESC]\X'pdf: markend'\m[]\c
 .   \"
@@ -735,5 +760,11 @@
 .de pdfmarkrestart
 .nop \!x X pdf: markrestart
 ..
+.de pdfpagename
+.nop \!x X pdf: pagename \\$1
+..
+.de pdfswitchtopage
+.nop \!x X pdf: switchtopage \\$*
+..
 .\"
 .\" pdf.tmac: end of file / vim: ft=groff



reply via email to

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