opentype.js icon indicating copy to clipboard operation
opentype.js copied to clipboard

Should use sfntVersion to pick glyph outlines

Open brawer opened this issue 5 years ago • 4 comments
trafficstars

OpenType.js should look at the sfntVersion field in the sfnt offset table to determine whether to use PostScript or TrueType outlines.

Expected Behavior

In the Unicode test suite for text rendering engines, test case SFNT-1 should pass.

Current Behavior

Test case SFNT-1 is failing.

Possible Solution

If a font contains both CFF and glyf tables, look at the sfntVersion field in the sfnt offset table to decide which one to use.

Steps to Reproduce (for bugs)

  1. On the OpenType.js site, load test font TestSFNTOne.otf and enter AB as string to display.
  2. Expected to see CFF underneath A and B; instead got this:

image

brawer avatar Dec 27 '19 09:12 brawer

I'm pretty sure that the test in question made the wrong assumption about what should happen in this particular case. Looking at the OpenType definition for sfntVersion, we see this clarification:

OpenType fonts that contain TrueType outlines should use the value of 0x00010000 for the sfntVersion. OpenType fonts containing CFF data (version 1 or 2) should use 0x4F54544F ('OTTO', when re-interpreted as a Tag) for sfntVersion.

Rather than saying "which data to use based on the version", the only prescription here is for "which version to use, based on the data".

At best we can only conclude that, because the sfntVersion field cannot be two values at once, whatever software generated this font did so incorrectly, giving us a font that is inconsistent with respect to the spec, and so should not even be accepted as a valid font (and someone needs to fix it).

Pomax avatar Dec 27 '19 16:12 Pomax

I’ve asked the community (at [email protected]) whether or not they’d like to have the test case, cc’ing you. Let’s discuss there. Personally I have no opinions here; it seems like a rather theoretical problem anyway.

brawer avatar Dec 31 '19 08:12 brawer

Was this ever resolved? Should we look at this or not?

Connum avatar Feb 17 '23 14:02 Connum

@brawer seeing you were recently active - any update on this?

Connum avatar Nov 25 '23 16:11 Connum