[NTG-pdftex] [PATCH v4] Allow .enc files for bitmap PK fonts

Pali Rohár pali.rohar at gmail.com
Fri Dec 15 19:12:14 CET 2017


On Friday 15 December 2017 17:13:22 Karl Berry wrote:
> (Sorry for the delayed reply.)
> 
>     Date: Sat, 19 Aug 2017 16:02:17 +0200
>     From: Pali Rohár <pali.rohar at gmail.com>
>     Subject: [PATCH v4] Allow .enc files for bitmap PK fonts
> 
> Thanks for splitting the patch into those separate pieces, Pali, and
> doing the test and documentation updates. Very helpful. Reading through
> the changes, they generally look fine.
> 
> My only question at the moment is, why do duplicate glyph names have to
> be removed in advance (in patch 3)? Otherwise we'll try to put two
> glyphs by the same (PostScript/PDF) name in the output font? Or
> something else? --thanks, karl.

Hi! Glyph names are put into /Differences PDF table and also glyphs
itself are identified in PDF by its names. So we cannot have two
different glyphs in PDF file with same name.

Function remove_duplicate_glyph_names() just remove duplicate glyph
names from enc file and later function writet3() for glyph index uses
either glyph name or if is not available (e.g. because of duplicates),
then it use name "a<glyph_index>" (like before). This ensures that every
glyph has a unique name in PDF file.

If you comment that remove_duplicate_glyph_names() then you would see
what happen. pdftex would not be able to create PDF file with two
different glyphs with same name and would store just one glyph. That
would result in damaged PDF font, one glyph would be used for all
characters which had associated that one glyph name in enc file.
Probably it would be the glyph with highest index.

Test case for reproducing should be easy:

File my.enc:
============
/my [
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef
/mychar /mychar
/.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
] def
============

File test.tex:
============
\pdfglyphtounicode{mychar}{269}
\pdfgentounicode=1
\pdfmapline{cmb10 <my.enc}
\font\cmb=cmb10
\cmb
a b
\bye
============

And result PDF file would not render glyph 'a' if function
remove_duplicate_glyph_names() is disabled. There would be two glyphs 'b'.

-- 
Pali Rohár
pali.rohar at gmail.com


More information about the ntg-pdftex mailing list