khaledhosny / ots

Sanitizer for OpenType
BSD 3-Clause "New" or "Revised" License
266 stars 63 forks source link

Cmap platform 0 encoding 1 is rejected #34

Closed behdad closed 10 years ago

behdad commented 10 years ago

It should work just like 0.0

sairuspatel commented 10 years ago

Originating context: When I investigated this InDesign-to-PDF workflow complaint raised in the Adobe Forum thread https://forums.adobe.com/message/6642223#6642223, I realized that Firefox's PDF viewer seemed to be rejecting font containing a (0,1) cmap subtable, and using a substitute font instead.

The designer in question was seeing that an annual report he'd produced for a client for years (using Mac OS' Helvetica Neue Light) was now showing up with substitute fonts in Firefox's PDF viewer.

I'd request that this OTS change be made and integrated by browsers as soon as possible, since the following Mac OS fonts contain a (0,1) cmap subtable:

My Mac OS 10.9.4 has the following fonts which contain a (0,1) cmap subtable:

BigCaslon-Medium Cochin Didot Futura-Medium HelveticaNeue-CondensedBold HelveticaNeue-CondensedBlack HelveticaNeue-UltraLight HelveticaNeue-UltraLightItalic HelveticaNeue-Light HelveticaNeue-LightItalic HelveticaNeue HelveticaNeue-Bold HelveticaNeue-BoldItalic Herculanum Optima-Regular Optima-Italic Optima-Bold Optima-BoldItalic Optima-ExtraBlack Papyrus Zapfino

a few of these also contain a (1,0) subtable, but most contain only a (0,1).

Thanks very much, Sairus Lead, Core Type Technologies Adobe

sairuspatel commented 10 years ago

Behdad said this omission in OTS wasn't by design and that the person who worked on this initially did it by a whitelist-as-needed strategy.

OTS does support various non-modern flavors of cmap encodings e.g. (1,0) and (0,0) so there’s no logical reason to exclude (0,1). See my previous comment on Mac OS fonts that have (0,1) cmap subtables.

behdad commented 10 years ago

Here's what should be supported and the order they should be preferred:

https://github.com/behdad/harfbuzz/blob/master/src/hb-ot-font.cc#L83

khaledhosny commented 10 years ago

We now accept 0-1-4 subtables and handle them just as 0-0-4 ones, but I’m worried that we output them as 3-1-4 subtables without doing anything special to the U+3400–U+4DFF range menthined in Apple’s cmap documentation, shouldn’t we be remapping them in some way?

jfkthame commented 10 years ago

ISTM it would be better/safer to keep 0-1-4 subtables separate, preserving them as 0-1-4 in the output rather than re-tagging them as 3-1-4 (which will be incorrect if those Hangul syllables were present).

If there's no 3-1-4 table present, AND if the 0-1-4 table does NOT include any codepoints in the 3400-4DFF range, then we could output the table as 3-1-4 instead, on the grounds that it's probably more widely recognized. But it's wrong to do this (without remapping) for a table that includes those codes.

sairuspatel commented 10 years ago

FYI, AFAIK no Adobe software does anything special with Unicode code points that were reassigned when reading (0,1) or other older flavors of cmap subtables. We just treat all of them as we would modern Unicode. (a) I haven't heard of an actual font out there that poses a problem, (b) the OT spec considers such older cmap subtable types to be deprecated, (c) vendors have had many years to update their fonts with a modern cmap subtable. For all these reasons, we decided it wouldn't be worth complicating our code in Adobe font engines.

behdad commented 10 years ago

Yeah, I don't think any special handling is worth it.

YellowYak commented 9 years ago

Has this fix been implemented by Firefox and Chrome? I ask because when using pdf.js to load a PDF document with the embedded Helvetica Neue font I get a substitution font and artifacts, as noted by sairuspatel back almost a year ago.

I posted an issue to pdf.js, https://github.com/mozilla/pdf.js/issues/6343, in which I have a PDF document that when viewed through https://mozilla.github.io/pdf.js/web/viewer.html renders the Helvetica Neue font correctly in Internet Explorer 11, but not in Firefox 39 or Chrome 44.

What version of OTS is being used by the latest versions of FF and Chrome? Are they using a version that includes the fix here?

Thanks

khaledhosny commented 9 years ago

This was fixed last year, so I suppose Chrome and Firefox got it by now, but you can check the source code of both to see what version of OTS they are using.