diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-02 00:17:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-02 00:17:17 +0000 |
commit | 35ff4f6a7d6f4f21e02bb3d494b182fd8b54bc7e (patch) | |
tree | 51486980b96c05a2f9de112e681d3c2f075d7b22 | |
parent | 3992bdafaa741b02f032e705d0aab10224c5c052 (diff) |
encoding vectors for bitmap font map lines (sync from pdftex r790)
git-svn-id: svn://tug.org/texlive/trunk@46189 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ChangeLog | 33 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/NEWS | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/mapfile.c | 32 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/pdftex.defines | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/pdftex.web | 10 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ptexlib.h | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ptexmac.h | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/writefont.c | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/writet3.c | 66 |
9 files changed, 147 insertions, 23 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index bbac2aee29e..38b0c800375 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,36 @@ +2018-01-01 Pali Roh\'ar <pali.rohar@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@yahoo.co.jp> * pdftex.web (compare_strings): Fix \pdfstrcmp error message diff --git a/Build/source/texk/web2c/pdftexdir/NEWS b/Build/source/texk/web2c/pdftexdir/NEWS index 9ef490d8ca4..b99fccb6902 100644 --- a/Build/source/texk/web2c/pdftexdir/NEWS +++ b/Build/source/texk/web2c/pdftexdir/NEWS @@ -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 diff --git a/Build/source/texk/web2c/pdftexdir/mapfile.c b/Build/source/texk/web2c/pdftexdir/mapfile.c index 026dc68b95e..fa153bcb60a 100644 --- a/Build/source/texk/web2c/pdftexdir/mapfile.c +++ b/Build/source/texk/web2c/pdftexdir/mapfile.c @@ -1,5 +1,6 @@ /* mapfile.c: handling of map files/lines -Copyright 1996-2017 Han The Thanh, <thanh@pdftex.org> + +Copyright 1996-2018 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -346,6 +347,27 @@ static int check_fm_entry(fm_entry * fm, boolean warn) 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 @@ static void fm_scan_line(void) 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 @@ boolean hasfmentry(internalfontnumber f) 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) diff --git a/Build/source/texk/web2c/pdftexdir/pdftex.defines b/Build/source/texk/web2c/pdftexdir/pdftex.defines index 192151364ca..ae42355c27e 100644 --- a/Build/source/texk/web2c/pdftexdir/pdftex.defines +++ b/Build/source/texk/web2c/pdftexdir/pdftex.defines @@ -1,5 +1,5 @@ -{ -Copyright 1996-2017 Han The Thanh, <thanh@pdftex.org> +{ pdftex.defines: Web2C pseudo-Pascal identifiers for pdfTeX. +Copyright 1996-2018 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -38,6 +38,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. { functions from mapfile.c } @define function hasfmentry(); +@define function isscalable(); @define procedure checkextfm(); @define procedure pdfmapfile(); @define procedure pdfmapline(); diff --git a/Build/source/texk/web2c/pdftexdir/pdftex.web b/Build/source/texk/web2c/pdftexdir/pdftex.web index c7552e264bf..b53a2345a84 100644 --- a/Build/source/texk/web2c/pdftexdir/pdftex.web +++ b/Build/source/texk/web2c/pdftexdir/pdftex.web @@ -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 @@ var w, s_out: scaled; 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 @@ begin {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 @@ begin 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 diff --git a/Build/source/texk/web2c/pdftexdir/ptexlib.h b/Build/source/texk/web2c/pdftexdir/ptexlib.h index becf40e96b2..dc3403f7677 100644 --- a/Build/source/texk/web2c/pdftexdir/ptexlib.h +++ b/Build/source/texk/web2c/pdftexdir/ptexlib.h @@ -1,5 +1,5 @@ -/* -Copyright 1996-2017 Han The Thanh, <thanh@pdftex.org> +/* ptexlib.h: macros for pdfTeX library code. +Copyright 1996-2018 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -168,6 +168,7 @@ extern const char *ptexbanner; /* 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 writet1(fd_entry *); 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 */ diff --git a/Build/source/texk/web2c/pdftexdir/ptexmac.h b/Build/source/texk/web2c/pdftexdir/ptexmac.h index 6b9a4ea5e64..54e12159245 100644 --- a/Build/source/texk/web2c/pdftexdir/ptexmac.h +++ b/Build/source/texk/web2c/pdftexdir/ptexmac.h @@ -1,5 +1,5 @@ -/* -Copyright 1996-2017 Han The Thanh, <thanh@pdftex.org> +/* ptexmac.h: common macros for pdfTeX. +Copyright 1996-2018 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -155,6 +155,7 @@ size_t T##_limit # 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 @@ size_t T##_limit # 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 @@ size_t T##_limit # 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 @@ size_t T##_limit # 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 diff --git a/Build/source/texk/web2c/pdftexdir/writefont.c b/Build/source/texk/web2c/pdftexdir/writefont.c index 45e0269fade..890e538bd61 100644 --- a/Build/source/texk/web2c/pdftexdir/writefont.c +++ b/Build/source/texk/web2c/pdftexdir/writefont.c @@ -1,5 +1,5 @@ -/* -Copyright 1996-2017 Han The Thanh, <thanh@pdftex.org> +/* writefont.c: font descriptors and writing Type 1 fonts. +Copyright 1996-2018 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -666,8 +666,8 @@ void dopdffont(integer font_objnum, internalfontnumber f) { 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); } diff --git a/Build/source/texk/web2c/pdftexdir/writet3.c b/Build/source/texk/web2c/pdftexdir/writet3.c index 3348dff5cff..f72ab32f944 100644 --- a/Build/source/texk/web2c/pdftexdir/writet3.c +++ b/Build/source/texk/web2c/pdftexdir/writet3.c @@ -1,5 +1,5 @@ -/* -Copyright 1996-2017 Han The Thanh, <thanh@pdftex.org> +/* writet3.c: write a Type 3 (bitmap PK) font. +Copyright 1996-2018 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -254,7 +254,34 @@ static boolean writepk(internalfontnumber f) 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; @@ -262,12 +289,19 @@ void writet3(int objnum, internalfontnumber f) 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++) { 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 @@ void writet3(int objnum, internalfontnumber f) 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 @@ void writet3(int objnum, internalfontnumber f) 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 @@ void writet3(int objnum, internalfontnumber f) 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 @@ void writet3(int objnum, internalfontnumber f) 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 @@ void writet3(int objnum, internalfontnumber f) 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(">"); |