texlive[46189] Build/source/texk/web2c/pdftexdir: encoding vectors

commits+karl at tug.org commits+karl at tug.org
Tue Jan 2 01:17:17 CET 2018


Revision: 46189
          http://tug.org/svn/texlive?view=revision&revision=46189
Author:   karl
Date:     2018-01-02 01:17:17 +0100 (Tue, 02 Jan 2018)
Log Message:
-----------
encoding vectors for bitmap font map lines (sync from pdftex r790)

Revision Links:
--------------
    http://tug.org/svn/texlive?view=revision&revision=790

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
    trunk/Build/source/texk/web2c/pdftexdir/NEWS
    trunk/Build/source/texk/web2c/pdftexdir/mapfile.c
    trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines
    trunk/Build/source/texk/web2c/pdftexdir/pdftex.web
    trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h
    trunk/Build/source/texk/web2c/pdftexdir/ptexmac.h
    trunk/Build/source/texk/web2c/pdftexdir/writefont.c
    trunk/Build/source/texk/web2c/pdftexdir/writet3.c

Modified: trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,3 +1,36 @@
+2018-01-01  Pali Roh\'ar <pali.rohar at gmail.com>
+
+	Patch 1: explicitly detect bitmap PK font in fm_scan_line,
+	instead of the implicit check of ps_name and ff_name being NULL.
+	* ptexmac.h (F_PK, set_pk, unset_pk, is_pk): new macros.
+	* writefont.c (dopdffont): call writet3 if is_pk.
+	* mapfile.c (fm_scan_line): call set_pk if no fontfile
+	and no ps_name on encoding line.
+
+	Patch 2: Always embed bitmap fonts with different sizes
+	separately, even if it has a fontmap entry; i.e., no geometric
+	scaling in the generated PDF.
+	* pdftex.defines (isscalable),
+	* ptexlib.h (isscalable),
+	* mapfile.c (isscalable): new fn.
+	* pdftex.web: call isscalable instead of hasfmentry
+	in all cases except @<Output fonts definition@>.
+		
+	Patch 3: Allow .enc files for bitmap PK fonts.
+	* ptexlib.h (writet3): take additional fm_entry* parameter.
+	* writefont.c (dopdffont): change call.
+	* writet3.c (writet3): change definition;
+	write_tounicode and encoding vector if we can.
+	(remove_duplicate_glyph_names): new fn.
+	
+	Patch 4: Additional checks for PK fonts in map file.
+	* mapfile.c (check_fm_entry): 
+
+	ChangeLog entry, some comments, error messages written or tweaked
+	by Karl Berry; all substantive code by Pali. Patch posted at
+	https://mailman.ntg.nl/pipermail/ntg-pdftex/2017-August/004183.html.
+	See test-pkmap.tex for more references and some tests.
+
 2017-12-16  Hironori Kitagawa  <h_kitagawa2001 at yahoo.co.jp>
 
 	* pdftex.web (compare_strings): Fix \pdfstrcmp error message

Modified: trunk/Build/source/texk/web2c/pdftexdir/NEWS
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/NEWS	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/NEWS	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,6 +1,7 @@
 - changes:
   - do not hash current directory into PDF ID, for more reproducible builds
     (pdftex r782).
+  - allow encoding vectors for bitmap PK fonts (r790).
 
 - bugfixes:
   - \pdfprimitive does nothing, rather than give an error, when given a

Modified: trunk/Build/source/texk/web2c/pdftexdir/mapfile.c
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/mapfile.c	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/mapfile.c	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,6 +1,7 @@
 /* mapfile.c: handling of map files/lines
-Copyright 1996-2017 Han The Thanh, <thanh at pdftex.org>
 
+Copyright 1996-2018 Han The Thanh, <thanh at pdftex.org>
+
 This file is part of pdfTeX.
 
 pdfTeX is free software; you can redistribute it and/or modify
@@ -346,6 +347,27 @@
         a += 32;
     }
 
+    /* font file for bitmap PK fonts is determinated by kpse and depends
+       on current font size; writet3.c ignores font file for bitmap PK fonts */
+    if (is_fontfile(fm) && is_pk(fm)) {
+        if (warn)
+            pdftex_warn
+                ("invalid entry for `%s': "
+                 "FontFile cannot be specified for bitmap PK font: %s",
+                 fm->tfm_name, fm_fontfile(fm));
+        a += 64;
+    }
+
+    /* ps name cannot be stored into PDF file for PDF Type3 fonts */
+    if (fm->ps_name != NULL && is_pk(fm)) {
+        if (warn)
+            pdftex_warn
+                ("invalid entry for `%s': "
+                 "PsName cannot be specified for bitmap PK font: %s",
+                 fm->tfm_name, fm->ps_name);
+        a += 128;
+    }
+
     return a;
 }
 
@@ -543,6 +565,9 @@
             set_opentype(fm);
         else
             set_type1(fm);
+    } else if (fm->ps_name == NULL) {
+        set_pk(fm);             /* font without ps_name and without fontfile,
+                                   it can be only bitmap PK font */
     } else
         set_type1(fm);          /* assume a builtin font is Type1 */
 
@@ -629,6 +654,11 @@
     return pdffontmap[f] != (fmentryptr) dummy_fm_entry();
 }
 
+boolean isscalable(internalfontnumber f)
+{
+    return hasfmentry(f) && (!is_pk((fm_entry *)pdffontmap[f]));
+}
+
 /* check whether a map entry is valid for font replacement */
 
 static boolean fm_valid_for_font_replacement(fm_entry * fm)

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,5 +1,5 @@
-{
-Copyright 1996-2017 Han The Thanh, <thanh at pdftex.org>
+{ pdftex.defines: Web2C pseudo-Pascal identifiers for pdfTeX.
+Copyright 1996-2018 Han The Thanh, <thanh at pdftex.org>
 
 This file is part of pdfTeX.
 
@@ -38,6 +38,7 @@
 
 { functions from mapfile.c }
 @define function hasfmentry();
+ at define function isscalable();
 @define procedure checkextfm();
 @define procedure pdfmapfile();
 @define procedure pdfmapline();

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.web
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,4 +1,4 @@
-% Copyright 1996-2017 Han Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh,
+% Copyright 1996-2018 Han Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh,
 % <thanh@@pdftex.org>
 
 % This file is part of pdfTeX.
@@ -15784,7 +15784,7 @@
     s: integer;
 begin
     w := char_width(f)(char_info(f)(c));
-    if hasfmentry(f) then begin
+    if isscalable(f) then begin
         if pdf_cur_Tm_a = 0 then begin
             call_func(divide_scaled(w, pdf_font_size[f], 4));
             pdf_delta_h := pdf_delta_h + scaled_out;
@@ -15995,7 +15995,7 @@
     {if |f| is auto expanded then ensure the base font is initialized}
     if pdf_font_auto_expand[f] and (pdf_font_blink[f] <> null_font) then begin
         b := pdf_font_blink[f];
-        if not hasfmentry(b) then
+        if not isscalable(b) then
             pdf_error("font expansion", "auto expansion is only possible with scalable fonts");
         if not font_used[b] then
             pdf_init_font(b);
@@ -16006,11 +16006,11 @@
     here: 1) |f| and |k| have the same tfm name (so they have been loaded at
     different sizes, eg 'cmr10' and 'cmr10 at 11pt'); 2) |f| has been auto
     expanded from |k|}
-    if hasfmentry(f) then begin
+    if isscalable(f) then begin
         i := head_tab[obj_type_font];
         while i <> 0 do begin
             k := obj_info(i);
-            if hasfmentry(k) and
+            if isscalable(k) and
                (pdf_font_map[k] = pdf_font_map[f]) and
                (str_eq_str(font_name[k], font_name[f]) or
                 (pdf_font_auto_expand[f] and

Modified: trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,5 +1,5 @@
-/*
-Copyright 1996-2017 Han The Thanh, <thanh at pdftex.org>
+/* ptexlib.h: macros for pdfTeX library code.
+Copyright 1996-2018 Han The Thanh, <thanh at pdftex.org>
 
 This file is part of pdfTeX.
 
@@ -168,6 +168,7 @@
 
 /* mapfile.c */
 extern boolean hasfmentry(internalfontnumber);
+extern boolean isscalable(internalfontnumber);
 extern void fm_free(void);
 extern void fm_read_info(void);
 extern ff_entry *check_ff_exist(char *, boolean);
@@ -307,7 +308,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: trunk/Build/source/texk/web2c/pdftexdir/ptexmac.h
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ptexmac.h	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/ptexmac.h	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,5 +1,5 @@
-/*
-Copyright 1996-2017 Han The Thanh, <thanh at pdftex.org>
+/* ptexmac.h: common macros for pdfTeX.
+Copyright 1996-2018 Han The Thanh, <thanh at pdftex.org>
 
 This file is part of pdfTeX.
 
@@ -155,6 +155,7 @@
 #  define F_TYPE1             0x10
 #  define F_TRUETYPE          0x20
 #  define F_OTF               0x40
+#  define F_PK                0x80
 
 #  define set_included(fm)    ((fm)->type |= F_INCLUDED)
 #  define set_subsetted(fm)   ((fm)->type |= F_SUBSETTED)
@@ -163,6 +164,7 @@
 #  define set_type1(fm)       ((fm)->type |= F_TYPE1)
 #  define set_truetype(fm)    ((fm)->type |= F_TRUETYPE)
 #  define set_opentype(fm)    ((fm)->type |= F_OTF)
+#  define set_pk(fm)          ((fm)->type |= F_PK)
 
 #  define unset_included(fm)  ((fm)->type &= ~F_INCLUDED)
 #  define unset_subsetted(fm) ((fm)->type &= ~F_SUBSETTED)
@@ -171,6 +173,7 @@
 #  define unset_type1(fm)     ((fm)->type &= ~F_TYPE1)
 #  define unset_truetype(fm)  ((fm)->type &= ~F_TRUETYPE)
 #  define unset_opentype(fm)  ((fm)->type &= ~F_OTF)
+#  define unset_pk(fm)        ((fm)->type &= ~F_PK)
 
 #  define is_included(fm)     (((fm)->type & F_INCLUDED) != 0)
 #  define is_subsetted(fm)    (((fm)->type & F_SUBSETTED) != 0)
@@ -179,6 +182,7 @@
 #  define is_type1(fm)        (((fm)->type & F_TYPE1) != 0)
 #  define is_truetype(fm)     (((fm)->type & F_TRUETYPE) != 0)
 #  define is_opentype(fm)     (((fm)->type & F_OTF) != 0)
+#  define is_pk(fm)           (((fm)->type & F_PK) != 0)
 
 #  define fm_slant(fm)        (fm)->slant
 #  define fm_extend(fm)       (fm)->extend

Modified: trunk/Build/source/texk/web2c/pdftexdir/writefont.c
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/writefont.c	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/writefont.c	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,5 +1,5 @@
-/*
-Copyright 1996-2017 Han The Thanh, <thanh at pdftex.org>
+/* writefont.c: font descriptors and writing Type 1 fonts.
+Copyright 1996-2018 Han The Thanh, <thanh at pdftex.org>
 
 This file is part of pdfTeX.
 
@@ -666,8 +666,8 @@
 {
     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);
+    if (fm == NULL || is_pk(fm))
+        writet3(fm, font_objnum, f);
     else
         create_fontdictionary(fm, font_objnum, f);
 }

Modified: trunk/Build/source/texk/web2c/pdftexdir/writet3.c
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/writet3.c	2018-01-01 22:07:01 UTC (rev 46188)
+++ trunk/Build/source/texk/web2c/pdftexdir/writet3.c	2018-01-02 00:17:17 UTC (rev 46189)
@@ -1,5 +1,5 @@
-/*
-Copyright 1996-2017 Han The Thanh, <thanh at pdftex.org>
+/* writet3.c: write a Type 3 (bitmap PK) font.
+Copyright 1996-2018 Han The Thanh, <thanh at pdftex.org>
 
 This file is part of pdfTeX.
 
@@ -254,8 +254,35 @@
     return true;
 }
 
-void writet3(int objnum, internalfontnumber f)
+/* We must remove duplicate glyph names since the duplicates render the
+   output invalid. We give a warning, since this should only happen with
+   ill-defined .enc files that should get fixed. */
+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 at position %d: %s",
+                        encname, i, g[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 +289,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 +298,10 @@
         t3_char_procs[i] = 0;
         t3_char_widths[i] = 0;
     }
+    fe = fm && fm->encname ? 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 +332,11 @@
         if (pdfcharmarked(f, i))
             break;
     last_char = i;
+    /* write ToUnicode entry if we can */
+    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);
@@ -326,6 +365,8 @@
     cptr = pdfnewobjnum();
     pdf_printf("/Widths %i 0 R\n/Encoding %i 0 R\n/CharProcs %i 0 R\n",
                (int) wptr, (int) eptr, (int) cptr);
+    if (tounicode_objnum != 0)
+        pdf_printf("/ToUnicode %i 0 R\n", (int) tounicode_objnum);
     pdfenddict();
     pdfbeginobj(wptr, 1);       /* chars width array */
     pdf_puts("[");
@@ -344,7 +385,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,7 +404,10 @@
                 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");
@@ -366,7 +415,12 @@
     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(">");



More information about the tex-live-commits mailing list