Fix CID Mac cmap: suppress empty stub, fix -cl off-by-one - #1848
Conversation
Two fixes for the Macintosh cmap subtable in CID-keyed font builds: 1. Suppress the empty Mac cmap subtable when no Mac CMap resource is provided via -cm. Previously makeCIDMaccmap() was called unconditionally, emitting a useless platform-1 subtable that mapped only .notdef. The OT spec discourages platform-1 subtables, and emitting an empty one just generates a confusing warning. Now the subtable is only created when -cm data is actually available. 2. Apply the spec-required +1 to the -cl value. The internal API convention (documented in hotconv.h) stores the Mac language field as "language ID + 1, or 0 if unspecific." All internal paths (codepage heuristics, CID fallback) honor this, but -cl passed the user's value through verbatim. So -cl 33 (Simplified Chinese) produced language=33 (which decodes as ID 32 per spec); the correct value is 34. The fix applies +1 at parse time for values >= 0, preserving -1 as the HOT_CMAP_UNKNOWN sentinel. Also fixes comment typo: -cl case said "script id", should be "language id". Fixes adobe-type-tools#1842 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The four expected TTX files that test -cl all had the old (wrong) language values. Now that -cl applies the spec-required +1, bump each: - t1pfa-cmap_cl2.ttx: language 2 → 3 - ufo2-cmap_cl5.ttx: language 5 → 6 - ufo3-cmap_cl5.ttx: language 5 → 6 - cidfont-cmap_cl3.ttx: language 3 → 4 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@frankrolf what do you think of this? |
|
Perhaps @hatchzo is more qualified to make an assessment here? |
|
Regarding For Adobe-Japan1 ROS-based fonts, an actual Macintosh cmap subtable is included. However, for fonts with the Adobe-Identity-0 ROS, the https://ccjktype.fonts.adobe.com/2013/06/ai0-and-heuristics.html I assume this may have been done with legacy compatibility in mind, such as environments that check for the presence of Macintosh cmap subtable, but I am not sure what the specific impact is. |
Summary
Two fixes for the Macintosh cmap subtable in CID-keyed font builds:
-cm. PreviouslymakeCIDMaccmap()was called unconditionally, emitting a useless platform-1 subtable mapping only .notdef. Now the subtable is only created when-cmdata is available.-cloff-by-one: apply the spec-required +1 to the user's value at parse time. The internal API convention (documented inhotconv.h:380-381) is "language ID + 1, or 0 if unspecific." All other paths honor this, but-clpassed through raw. So-cl 33(Simplified Chinese) producedlanguage=33(decodes as ID 32 per spec); correct value is 34.-clcase said "script id", should be "language id".Fixes #1842
Questions for reviewer
Backwards compatibility of suppression: Could any existing CID workflow depend on the empty platform-1 stub being present? The spec discourages Mac cmap subtables and the stub maps nothing useful, but it's a behavior change. The warning message is retained (with updated text) so users will know what changed.
Should the warning be downgraded to INFO? The reporter notes it's confusing to warn about a missing resource for a subtable the user never asked for. Now that we suppress the subtable, the warning is purely informational ("we didn't make a Mac cmap because you didn't give us Mac CMap data").
Should
-cldocument the change? The fix means existing scripts passing-clvalues will now get different (correct) output. Anyone who was compensating by passing the already-incremented value will now be off by one in the other direction. Probably fine since the old behavior was simply wrong, but worth noting.Test plan
-cm🤖 Generated with Claude Code