pdf-issues icon indicating copy to clipboard operation
pdf-issues copied to clipboard

Can CFF fonts which use CIDFont operators in their Top DICT be simple PDF fonts?

Open seehuhn opened this issue 1 year ago • 2 comments

Table 124 (Embedded font organisation for various font types) in the PDF-2.0 spec lists the cases when an OpenType font which uses CFF data can be embedded as a font program for a PDF font. The cases listed (in the FontFile3/OpenType row) are

A CIDFontType0 CIDFont dictionary, if the embedded font program contains a "CFF " [...] table with a Top DICT that uses CIDFont operators (this is equivalent to subtype CIDFontType0C).

and

A Type1 font dictionary or CIDFontType0 CIDFont dictionary, if the embedded font program contains a "CFF " table without CIDFont operators.

This list includes only three out of the four possible combinations of simple/composite and presence/absence of CIDFont operators. It does not allow fonts with a "CFF " table where a Top DICT that uses CIDFont operators is present in Type1 font dictionaries.

In contrast, the rules for directly embedding the CFF font data without the OpenType wrapper have no such restrictions: The FontFile3/Type1C row simply states that the following font type can be embedded:

Type 1–equivalent font program represented in the Compact Font Format (CFF), as described in Adobe Technical Note #5176 [...]. This entry may appear in the font descriptor for a Type1 or MMType1 font dictionary.

Technical note #5176 includes CID-keyed fonts, so CFF fonts with a Top DICT that uses CIDFont operators seem to be allowed here. (This is, unless additional restrictions hide in the term "type 1-equivalent"; I could not find a definition of this term.)

This seems to be an odd contradiction.

If CFF fonts with a Top DICT that uses CIDFont operators are in fact allowed for Type1 font dictionaries, my suggestion would be to add a note in the OpenType section, to explain that the restriction there can be worked around by directly embedding the contents of the "CFF " table as described in row FontFile3/Type1C.

On the other hand, if such fonts are not allowed in a Type1 font dict, this should be stated in the FontFile3/Type1C row of the table.

seehuhn avatar Sep 18 '24 13:09 seehuhn

Thinking this through some more: I believe that CFF fonts which use CIDFont operators do not include glyph names, so these cannot possibly work for simple fonts. If this is true, my suggestion would be to just add the following sentence to the existing text in the FontFile3/Type1C row of the table:

Only CFF font programs without CIDFont operators can be used here.

Maybe this is also what "Type 1-equivalent" is attempting to mean?

seehuhn avatar Sep 19 '24 11:09 seehuhn

I had the feeling that the restriction "with a Top DICT that uses CIDFont operators" for a /FontFile3 with subtype /OpenType at page 353 of ISO 32000-2:2020 is undue. I'm assuming that a CFF font that has such operators is basically a CID-Keyed font (I hope I'm correct in this interpretation). At page 332 this clarified why, in my undestanding, it's already assumed that a /FontFile3 can be either a regular/converted Type1 font or a CID-Keyed font:

When the CIDFont contains an embedded font program that is represented in the Compact Font Format (CFF), the FontFile3 entry in the font descriptor (see "Table 124 — Embedded font organisation for various font types") shall be either CIDFontType0C or OpenType. There are two cases, depending on the contents of the font program: • The "CFF" font program has a Top DICT that uses CIDFont operators: The CIDs shall be used to determine the GID value for the glyph procedure using the charset table in the CFF program. The GID value shall then be used to look up the glyph procedure using the CharStrings INDEX table (as defined by Adobe Technical Note #5177, The Type 2 Charstring Format). NOTE Although in many fonts the CID value and GID value are the same, the CID and GID values can differ. • The "CFF" font program has a Top DICT that does not use CIDFont operators: The CIDs shall be used directly as GID values, and the glyph procedure shall be retrieved using the CharStrings INDEX (refer to Adobe Technical Note #5177, The Type 2 Charstring Format).

Also consider that CID-Keyed fonts are not very frequent as are they mostly used for CJK languages working together predefined CMap(s). For latin languages CFF fonts are mostly frequently used together the CMap CID mapping embedded in the font in the /Encoding key, which it makes the PDF composite font a CIDFont unconditionally. In fact TrueType font programs are not CID keyed, but they can be still used in a CIDFont as defined by PDF specification.

ceztko avatar Nov 27 '24 11:11 ceztko