pdftex[772] branches/stable/tests: allow .enc files for bitmap fonts,

commits+karl at tug.org commits+karl at tug.org
Thu Mar 16 23:58:04 CET 2017


Revision: 772
          http://tug.org/svn/pdftex?view=revision&revision=772
Author:   karl
Date:     2017-03-16 23:58:04 +0100 (Thu, 16 Mar 2017)
Log Message:
-----------
allow .enc files for bitmap fonts, from Pali Rohar

Modified Paths:
--------------
    branches/stable/doc/manual/ChangeLog
    branches/stable/doc/manual/pdftex-t.tex
    branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog
    branches/stable/source/src/texk/web2c/pdftexdir/NEWS
    branches/stable/source/src/texk/web2c/pdftexdir/mapfile.c
    branches/stable/source/src/texk/web2c/pdftexdir/ptexlib.h
    branches/stable/source/src/texk/web2c/pdftexdir/writefont.c
    branches/stable/source/src/texk/web2c/pdftexdir/writet3.c
    branches/stable/tests/01-fake-interword-space/Makefile
    branches/stable/tests/02-pdfmatch/Makefile
    branches/stable/tests/03-deterministic-output/Makefile
    branches/stable/tests/04-pdfsuppressptexinfo/Makefile
    branches/stable/tests/05-mediabox/Makefile
    branches/stable/tests/05-mediabox/test-normal.tex
    branches/stable/tests/05-mediabox/test-omit-mediabox.tex
    branches/stable/tests/Common.mak

Added Paths:
-----------
    branches/stable/tests/06-pkenc/
    branches/stable/tests/06-pkenc/Makefile
    branches/stable/tests/06-pkenc/cmb10.72pk
    branches/stable/tests/06-pkenc/prepatch.pdf
    branches/stable/tests/06-pkenc/test-pkenc.tex

Property Changed:
----------------
    branches/stable/tests/05-mediabox/test-normal.tex
    branches/stable/tests/05-mediabox/test-omit-mediabox.tex

Modified: branches/stable/doc/manual/ChangeLog
===================================================================
--- branches/stable/doc/manual/ChangeLog	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/doc/manual/ChangeLog	2017-03-16 22:58:04 UTC (rev 772)
@@ -1,3 +1,11 @@
+2017-03-16  Karl Berry  <karl at freefriends.org>
+
+	* pdftex-t.tex (Map files) <encodingfile>: can be specified for
+	bitmap PK fonts now also.
+
+	* pdftex-t.tex (\tagcode): use <8-bit number> like everything else,
+	rather than <character code>. Report from Doug McKenna.
+
 2017-02-18  Karl Berry  <karl at freefriends.org>
 
 	* pdftex-t.tex (\pdfpageattr): document new behavior of

Modified: branches/stable/doc/manual/pdftex-t.tex
===================================================================
--- branches/stable/doc/manual/pdftex-t.tex	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/doc/manual/pdftex-t.tex	2017-03-16 22:58:04 UTC (rev 772)
@@ -1604,9 +1604,9 @@
 
 \startdescription {encodingfile}
 specifies the name of the file containing the external encoding vector
-to be used for the font. The encoding file must have name extension
+to be used for the font. The encoding file name must have the extension
 \type{.enc}, and the full file name including this extension must be given
-with preceding~\type{<} character. The format of the encoding vector is
+with a preceding~\type{<} character. The format of the encoding vector is
 identical to that used by \type{dvips}. If no encoding is specified,
 the font's built||in default encoding is used. The {\em encodingfile}
 field may be omitted if you are sure that the font resource has the
@@ -1613,11 +1613,27 @@
 correct built||in encoding. In general this option is highly recommended,
 and it is {\em required} when subsetting a TrueType font.
 
+As of version 1.40.18, the encoding file can be specified also for
+bitmap \PK\ fonts. In this case, it assigns the glyph names from the
+given encoding vector, which can be used with the
+\type{\pdfgentounicode} primitive (q.v.).  For example: 
+
+\starttyping
+\pdfglyphtounicode{ffi}{0066 0066 0069} % normally: \input glyphtounicode
+\pdfgentounicode=1
+\pdfmapline{cmb10 <7t.enc}
+\font\cmb=cmb10 \cmb ffi
+\stoptyping
+
+The result is a \PDF\ file with a correctly-labeled \type{/ffi}
+character instead of the numeric character position in the
+\type{cmb10.tfm} (decimal 14).
+
 \stopdescription
 
 \startdescription {fontfile}
 sets the name of the font file to be embedded into the \PDF\ output for a
-given \TeX\ font (the {\em tfmname}~$\longleftrightarrow$~{\em fontfile}
+given \TeX\ font (the {\em tfmname}~$\leftrightarrow$~{\em fontfile}
 mapping is the most prominent use of the \filename{pdftex.map} file).
 The font file name must belong to a Type~1 or TrueType font file. If
 the {\em fontfile} field is missing, no font embedding can take place;
@@ -2951,7 +2967,7 @@
 \introduced{1.30.0}
 
 \pdftexprimitive{\Syntax{\Tex{\tagcode} \Something{font}
-  \Something{character code} \Whatever{integer}}}
+  \Something{8-bit number} \Whatever{integer}}}
 \bookmark{\tex{tagcode}}
 
 This primitive accesses a character's \type{char_tag} info. It is meant

Modified: branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog	2017-03-16 22:58:04 UTC (rev 772)
@@ -1,3 +1,16 @@
+2017-03-16  Pali Roh\'ar <pali.rohar at gmail.com>
+
+	Allow .enc files for bitmap fonts, following thread at
+	http://tug.org/pipermail/pdftex/2016-July/009064.html
+	http://tug.org/pipermail/pdftex/2016-August/009065.html:
+	* writet3.c (remove_duplicate_glyph_names): new fn.
+	(writet3): change fn to take fm_entry object, and use it to write
+	glyph names from an enc file, if specified in the map file.
+	(write_fontdictionary): 
+	* ptexlib.h (writet3): change declaration.
+	* writefont.c (dopdffont): change call to writet3.
+	* mapfile.c (check_fm_entry): also report missing enc file.
+
 2017-02-18  Heiko Oberdiek  <heiko.oberdiek at googlemail.com>
 
 	* pdftex.web (substr_of_str): move earlier.

Modified: branches/stable/source/src/texk/web2c/pdftexdir/NEWS
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/NEWS	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/source/src/texk/web2c/pdftexdir/NEWS	2017-03-16 22:58:04 UTC (rev 772)
@@ -1,5 +1,6 @@
 pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017)
 - changes:
+  - encoding files can be specified for PK bitmap fonts on font map lines.
   - rename envvar SOURCE_DATE_EPOCH_TEX_PRIMITIVES to FORCE_SOURCE_DATE;
     no changes in functionality.
   - if the \pdfpageattr token list contains the string "/MediaBox",

Modified: branches/stable/source/src/texk/web2c/pdftexdir/mapfile.c
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/mapfile.c	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/source/src/texk/web2c/pdftexdir/mapfile.c	2017-03-16 22:58:04 UTC (rev 772)
@@ -288,11 +288,11 @@
         /* do not set variable |a| as this entry will be still accepted */
     }
 
-    /* if both ps_name and font file are missing, drop this entry */
-    if (fm->ps_name == NULL && !is_fontfile(fm)) {
+    /* if ps_name, font file and enc file are missing, drop this entry */
+    if (fm->ps_name == NULL && !is_fontfile(fm) && !is_reencoded(fm)) {
         if (warn)
             pdftex_warn
-                ("invalid entry for `%s': both ps_name and font file missing",
+                ("invalid entry for `%s': ps_name, font file, enc file all missing",
                  fm->tfm_name);
         a += 1;
     }

Modified: branches/stable/source/src/texk/web2c/pdftexdir/ptexlib.h
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/ptexlib.h	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/source/src/texk/web2c/pdftexdir/ptexlib.h	2017-03-16 22:58:04 UTC (rev 772)
@@ -307,7 +307,7 @@
 extern void t1_free(void);
 
 /* writet3.c */
-extern void writet3(int, internalfontnumber);
+extern void writet3(fm_entry *, int, internalfontnumber);
 extern scaled getpkcharwidth(internalfontnumber, scaled);
 
 /* writettf.c */

Modified: branches/stable/source/src/texk/web2c/pdftexdir/writefont.c
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/writefont.c	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/source/src/texk/web2c/pdftexdir/writefont.c	2017-03-16 22:58:04 UTC (rev 772)
@@ -667,7 +667,7 @@
     fm_entry *fm;
     fm = hasfmentry(f) ? (fm_entry *) pdffontmap[f] : NULL;
     if (fm == NULL || (fm->ps_name == NULL && fm->ff_name == NULL))
-        writet3(font_objnum, f);
+        writet3(fm, font_objnum, f);
     else
         create_fontdictionary(fm, font_objnum, f);
 }

Modified: branches/stable/source/src/texk/web2c/pdftexdir/writet3.c
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/writet3.c	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/source/src/texk/web2c/pdftexdir/writet3.c	2017-03-16 22:58:04 UTC (rev 772)
@@ -254,8 +254,32 @@
     return true;
 }
 
-void writet3(int objnum, internalfontnumber f)
+static void remove_duplicate_glyph_names(char **g, const char *encname)
 {
+    struct avl_table *gl_tree;
+    char *aa;
+    int i;
+    gl_tree = avl_create(comp_string_entry, NULL, &avl_xallocator);
+    assert(gl_tree != NULL);
+    for (i = 0; i < 256; i++) {
+        if (g[i] == notdef)
+            continue;
+        aa = (char *) avl_find(gl_tree, g[i]);
+        if (aa == NULL) {
+            aa = (char *) avl_probe(gl_tree, g[i]);
+            assert(aa != NULL);
+        } else {
+            pdftex_warn("%s: duplicate glyph name `%s' at position %d",
+                        encname, g[i], i);
+            xfree(g[i]);
+            g[i] = (char *) notdef;
+        }
+    }
+    avl_destroy(gl_tree, NULL);
+}
+
+void writet3(fm_entry * fm, int objnum, internalfontnumber f)
+{
     static char t3_font_scale_str[] = "\\pdffontscale";
     int i;
     integer wptr, eptr, cptr;
@@ -262,6 +286,9 @@
     int first_char, last_char;
     integer pk_font_scale;
     boolean is_notdef;
+    fe_entry *fe;
+    char **glyph_names;
+    integer tounicode_objnum;
     t3_glyph_num = 0;
     t3_image_used = false;
     for (i = 0; i < 256; i++) {
@@ -268,6 +295,10 @@
         t3_char_procs[i] = 0;
         t3_char_widths[i] = 0;
     }
+    fe = fm ? get_fe_entry(fm->encname) : NULL;
+    glyph_names = fe ? fe->glyph_names : NULL;
+    if (glyph_names)
+        remove_duplicate_glyph_names(glyph_names, fm->encname);
     packfilename(fontname[f], getnullstr(), maketexstring(".pgc"));
     cur_file_name = makecstring(makenamestring());
     is_pk_font = false;
@@ -298,6 +329,11 @@
         if (pdfcharmarked(f, i))
             break;
     last_char = i;
+    /* write ToUnicode entry if needed */
+    if (fixedgentounicode > 0 && !pdffontnobuiltintounicode[f] && fe != NULL)
+        tounicode_objnum = write_tounicode(glyph_names, fm->tfm_name,fe->name);
+    else
+        tounicode_objnum = 0;
     pdfbegindict(objnum, 1);    /* Type 3 font dictionary */
     pdf_puts("/Type /Font\n/Subtype /Type3\n");
     pdf_printf("/Name /F%i\n", (int) f);
@@ -344,7 +380,12 @@
         pdf_printf("/%s", notdef);
         is_notdef = true;
     } else {
-        pdf_printf("/a%i", first_char);
+        if (glyph_names
+            && glyph_names[first_char]
+            && glyph_names[first_char] != notdef)
+            pdf_printf("/%s", glyph_names[first_char]);
+        else
+            pdf_printf("/a%i", first_char);
         is_notdef = false;
     }
     for (i = first_char + 1; i <= last_char; i++) {
@@ -358,15 +399,25 @@
                 pdf_printf(" %i", i);
                 is_notdef = false;
             }
-            pdf_printf("/a%i", i);
+            if (glyph_names && glyph_names[i] && glyph_names[i] != notdef)
+                pdf_printf("/%s", glyph_names[i]);
+            else
+                pdf_printf("/a%i", i);
         }
     }
     pdf_puts("]\n");
+    if (tounicode_objnum != 0)
+        pdf_printf("/ToUnicode %i 0 R\n", (int) tounicode_objnum);
     pdfenddict();
     pdfbegindict(cptr, 1);      /* CharProcs dictionary */
     for (i = first_char; i <= last_char; i++)
         if (t3_char_procs[i] != 0)
-            pdf_printf("/a%i %i 0 R\n", (int) i, (int) t3_char_procs[i]);
+            if (glyph_names && glyph_names[i] && glyph_names[i] != notdef)
+                pdf_printf("/%s %i 0 R\n", glyph_names[i], 
+                           (int) t3_char_procs[i]);
+            else
+                pdf_printf("/a%i %i 0 R\n", (int) i,
+                           (int) t3_char_procs[i]);
     pdfenddict();
     t3_close();
     tex_printf(">");

Modified: branches/stable/tests/01-fake-interword-space/Makefile
===================================================================
--- branches/stable/tests/01-fake-interword-space/Makefile	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/01-fake-interword-space/Makefile	2017-03-16 22:58:04 UTC (rev 772)
@@ -1,5 +1,7 @@
+# Public domain.
+
 test:
 	../../source/build-pdftex/texk/web2c/pdftex -ini fake-interword-space.tex
 
 clean:
-	rm -f fake-interword-space.log fake-interword-space.pdf
+	$(clean)

Modified: branches/stable/tests/02-pdfmatch/Makefile
===================================================================
--- branches/stable/tests/02-pdfmatch/Makefile	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/02-pdfmatch/Makefile	2017-03-16 22:58:04 UTC (rev 772)
@@ -6,3 +6,5 @@
 testpdfmatch:
 	$(prog) test-pdfmatch.tex
 
+clean:
+	$(clean)

Modified: branches/stable/tests/03-deterministic-output/Makefile
===================================================================
--- branches/stable/tests/03-deterministic-output/Makefile	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/03-deterministic-output/Makefile	2017-03-16 22:58:04 UTC (rev 772)
@@ -41,7 +41,7 @@
 force:
 
 clean:
-	rm -f *.log *.pdf *.fmt *.aux
+	$(clean)
 
 fmt:
 	$(prog) \*pdflatex.ini

Modified: branches/stable/tests/04-pdfsuppressptexinfo/Makefile
===================================================================
--- branches/stable/tests/04-pdfsuppressptexinfo/Makefile	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/04-pdfsuppressptexinfo/Makefile	2017-03-16 22:58:04 UTC (rev 772)
@@ -37,4 +37,4 @@
 	-$(diff) $^  # new /mytrlrkey, dates+id should be different
 
 clean:
-	rm -f *.log *.pdf *.fmt *.aux
+	$(clean)

Modified: branches/stable/tests/05-mediabox/Makefile
===================================================================
--- branches/stable/tests/05-mediabox/Makefile	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/05-mediabox/Makefile	2017-03-16 22:58:04 UTC (rev 772)
@@ -14,11 +14,5 @@
 	grep -q /MediaBox.*271 test-omit-mediabox.pdf   # should be there
 	! grep -q /MediaBox.*314 test-omit-mediabox.pdf # should not
 
-force:
-
 clean:
-	rm -f *.log *.pdf *.fmt *.aux
-
-fmt:
-	$(prog) \*pdflatex.ini
-	$(prog) \*pdfetex.ini
+	$(clean)

Modified: branches/stable/tests/05-mediabox/test-normal.tex
===================================================================
--- branches/stable/tests/05-mediabox/test-normal.tex	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/05-mediabox/test-normal.tex	2017-03-16 22:58:04 UTC (rev 772)
@@ -1,3 +1,6 @@
+% $Id$
+% Public domain.
+
 \pdfoutput=1
 \pdfpagewidth=314bp
 \pdfpageheight=315bp


Property changes on: branches/stable/tests/05-mediabox/test-normal.tex
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id
\ No newline at end of property
Modified: branches/stable/tests/05-mediabox/test-omit-mediabox.tex
===================================================================
--- branches/stable/tests/05-mediabox/test-omit-mediabox.tex	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/05-mediabox/test-omit-mediabox.tex	2017-03-16 22:58:04 UTC (rev 772)
@@ -1,3 +1,6 @@
+% $Id$
+% Public domain.
+
 \pdfoutput=1 \catcode`\{=1 \catcode`\}=2
 \pdfpagewidth=314bp
 \pdfpageheight=315bp


Property changes on: branches/stable/tests/05-mediabox/test-omit-mediabox.tex
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id
\ No newline at end of property
Index: branches/stable/tests/06-pkenc
===================================================================
--- branches/stable/tests/06-pkenc	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/06-pkenc	2017-03-16 22:58:04 UTC (rev 772)

Property changes on: branches/stable/tests/06-pkenc
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+test-pkenc.pdf
Added: branches/stable/tests/06-pkenc/Makefile
===================================================================
--- branches/stable/tests/06-pkenc/Makefile	                        (rev 0)
+++ branches/stable/tests/06-pkenc/Makefile	2017-03-16 22:58:04 UTC (rev 772)
@@ -0,0 +1,13 @@
+# $Id$
+# Public domain.
+
+include ../Common.mak
+
+default: test-pkenc
+
+test-pkenc:
+	$(prog) test-pkenc.tex
+	grep -q /ffi test-pkenc.pdf # should end up with this encoded char
+
+clean:
+	$(clean)


Property changes on: branches/stable/tests/06-pkenc/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id
\ No newline at end of property
Added: branches/stable/tests/06-pkenc/cmb10.72pk
===================================================================
(Binary files differ)

Index: branches/stable/tests/06-pkenc/cmb10.72pk
===================================================================
--- branches/stable/tests/06-pkenc/cmb10.72pk	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/06-pkenc/cmb10.72pk	2017-03-16 22:58:04 UTC (rev 772)

Property changes on: branches/stable/tests/06-pkenc/cmb10.72pk
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: branches/stable/tests/06-pkenc/prepatch.pdf
===================================================================
(Binary files differ)

Index: branches/stable/tests/06-pkenc/prepatch.pdf
===================================================================
--- branches/stable/tests/06-pkenc/prepatch.pdf	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/06-pkenc/prepatch.pdf	2017-03-16 22:58:04 UTC (rev 772)

Property changes on: branches/stable/tests/06-pkenc/prepatch.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/stable/tests/06-pkenc/test-pkenc.tex
===================================================================
--- branches/stable/tests/06-pkenc/test-pkenc.tex	                        (rev 0)
+++ branches/stable/tests/06-pkenc/test-pkenc.tex	2017-03-16 22:58:04 UTC (rev 772)
@@ -0,0 +1,25 @@
+% $Id$
+% Public domain.
+% Test encoding files with bitmap (i.e., Type 3) fonts.
+% See thread starting here:
+%   http://tug.org/pipermail/pdftex/2016-July/009064.html
+% and continuing here:
+%   http://tug.org/pipermail/pdftex/2016-August/009065.html
+%
+% For comparison, the PDF made before the patch was applied is saved
+% here as prepatch.pdf.
+% 
+% The default PK resolution is 72, so we made cmb10.72pk in this directory.
+% (mf-nowin '\mode:=mactrue; input cmb10' && gftopk cmb10.72gf)
+%
+\pdfoutput=1 \catcode`\{=1 \catcode`\}=2 \hsize=4pc
+
+\pdfglyphtounicode{ffi}{0066 0066 0069} %no need for all: \input glyphtounicode
+\pdfgentounicode=1
+
+\pdfmapline{cmb10 <7t.enc}
+\font\cmb=cmb10
+
+\noindent \cmb ffi
+\hbadness=10000 % line is underfull for some reason
+\end


Property changes on: branches/stable/tests/06-pkenc/test-pkenc.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id
\ No newline at end of property
Modified: branches/stable/tests/Common.mak
===================================================================
--- branches/stable/tests/Common.mak	2017-03-13 22:46:11 UTC (rev 771)
+++ branches/stable/tests/Common.mak	2017-03-16 22:58:04 UTC (rev 772)
@@ -17,9 +17,11 @@
 t1_cm = $(tl_dist)/fonts/type1/public/amsfonts/cm
 #
 env = TEXINPUTS=.:$(plain):$(plain_config):$(generic_config):$(generic_hyphen)\
-      TEXFONTS=$(tfm_cm):$(tfm_knuth):$(t1_cm) \
+      TEXFONTS=.:$(tfm_cm):$(tfm_knuth):$(t1_cm) \
       TEXFONTMAPS=$(tl_dist)/fonts/map/pdftex/updmap \
+      ENCFONTS=$(tl_dist)/fonts/enc/dvips/base \
       MKTEXTFM=0 \
+      MKTEXPK=0 \
       KPATHSEA_WARNING=0
 
 diff = diff --text -c0
@@ -26,3 +28,6 @@
 
 pdftex = ../../source/build-pdftex/texk/web2c/pdftex
 prog = $(env) $(pdftex) -ini -interaction=nonstopmode
+
+# can't make the clean: target here since then it would be the default.
+clean = rm -f *.log *.pdf *.fmt *.aux



More information about the pdftex-commits mailing list