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

Update docs for Font.getPath to explain what happens with cutout subpaths

Open Pomax opened this issue 7 years ago • 3 comments

Right now the API docs for Font.getPath in the README.md do not explain what happens with paths that include cutout subpaths (the letter O being an obvious candidate). The OpenType spec itself allows for three possible cases:

  • CFF/Type2 outlines rely on crossing number, so any subpath B contained by outermost subpath A is a cutout, any subpath C inside subpath B is a fill, any subpath D inside C is a cutout, etc.
  • TTF outlines rely on path direction, so in the above example B is only a cutout for A if either A is defined clockwise and B is defined counter-clockwise.
  • SVG outlines rely on "literally whichever you want" because glyphs are specified using SVG1.1 documents which means that the fillrule attribute can be used to specify whether crossing (fillrule="evenodd") or direction (fillrule="nonzero") is used.

Right now the API docs don't say whether OpenType.js yields the paths as specified in the font, with a way to look up what the cutout algorithm needs to be per glyph, or whether it rewrites paths so that a glyph looks correct when rendered using the currently also unspecified cutout algorithm =)

Can that get an update?

Pomax avatar Jun 04 '18 16:06 Pomax

Are you volunteering for a pull request? :)

axkibe avatar Jun 04 '18 16:06 axkibe

I am not, because I haven't looked at the code in literally over a year, and am working on too many projects already right now to do a deep dive into the current code before I know which of these things OpenType.js does.

Pomax avatar Jun 04 '18 16:06 Pomax

Any updating here?

random-yang avatar Nov 24 '21 13:11 random-yang