adobe-type-tools / afdko

Adobe Font Development Kit for OpenType
https://adobe-type-tools.github.io/afdko/
Other
1.01k stars 166 forks source link

[tx] Valid operators in Font DICT of CID-keyed CFF #137

Open mashabow opened 8 years ago

mashabow commented 8 years ago

According to cffwrite_dict.c or absfont.h, it seems only four operators are valid in Font DICT:

Are they explicitly stated in some technotes? I couldn't find it...

kenlunde commented 8 years ago

While not explicitly stated, I think that the closest Adobe Tech Note is #5014, which implicitly states this via its examples. (There is also FontType, which is a fifth operator, though I suspect that it is not necessary for CFF (because its value is implicit in CFF), but for CIDFont resources.)

mashabow commented 8 years ago

Thank you for clarifying!

BTW, fontTools' cffLib can complie any Top DICT operators that appear in Font DICT (see cffLib.py#L1434). How should we treat such invalid entries? Just ignore or undefined behavior? tx -t1 seems to treat the last value of each operator as the actual Top DICT's value.

readroberts commented 8 years ago

This is a bug in 'tx'. I will change 'tx' to ignore any such operators: it will just pop the operator and its operands from the stack, and emit a warning.

anthrotype commented 8 years ago

@mashabow if you think cffLib needs fixing, could you also file an issue on the fontTools repo? Thanks.

readroberts commented 8 years ago

The closest I can find to a definition for an FDArray FontDict is from Tech Note 5014 page 31. I include this below. This section excludes only a couple of keys and says otherwise that an FDArray FontDict is a PostScript FontDict, which implies that all other keys are permissible. However, I think this is an oversight in the spec, and I agree with Ken Lunde's list for keys that are actually used. Furthermore, most of the other TopDict keys are used in text layout and. in the context of OpenType, are ignored as they overridden by data in other OpenType tables.

from Page 31, Tech Note 5014. 11 June 1993:

Each font dictionary in a CIDFont of CIDFontType 0 is a font dictionary as described in the PostScript Language Reference Manual, Second Edition, with certain exceptions. These font dictionaries may be Type 1 or Type 3 font dictionaries, but must not include the following entries: Type 1 Exceptions Encoding Array Should not be present in an FDArray font dictionary because the CMap file controls encoding. Charstring Dictionary Should not be present in an FDArray font dictionary because charstring information appears in a data block near the end of the CIDFont file. 32 Adobe CMap and CIDFont Files Specification (11 June 93) Subrs Array Should not be present in an FDArray font dictionary because subroutine information appears in a data block near the end of a CIDFont file along with charstrings and offset and index information. Type 3 Exceptions Encoding Array Should not be present in an FDArray font dictionary because the CMap file controls encoding.

kenlunde commented 8 years ago

This is Table 5-14 from page 374 of the PostScript Language Reference Manual.

plrm-p374-t5-14

mashabow commented 8 years ago

@anthrotype:

if you think cffLib needs fixing, could you also file an issue on the fontTools repo? Thanks.

OK, I will open an issue there.

@kenlunde:

This is Table 5-14 from page 374 of the PostScript Language Reference Manual.

Oh, I missed that table. Thanks. So I may summarize it for CID-keyed CFF as follows, right?

kenlunde commented 8 years ago

@mashabow: About your last bullet point, Adobe Tech Note 5014 doesn't have Table 9 nor Table 10. To which document are you referring? 5176, I think.

mashabow commented 8 years ago

@kenlunde Oops, I meant 5176, yes.

kenlunde commented 8 years ago

👌