opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.38k stars 468 forks source link

Support CFF2 #249

Closed brawer closed 1 year ago

brawer commented 7 years ago

Specification: https://www.microsoft.com/typography/otspec/cff2.htm

Tests: https://raw.githack.com/unicode-org/text-rendering-tests/master/reports/FreeStack.html#CFF2-1

Test font: https://github.com/adobe-fonts/adobe-variable-font-prototype/releases/tag/1.001

fdb commented 7 years ago

Yes, it would be awesome if we could support this! Thanks for posting the test font.

tshinnic commented 7 years ago

Unfortunately that test font also has lots of new 'prototype' stuff for font variations. It would be wonderful to find a 'plain' sample file or three of fonts with CFF2 tables. (sigh)

BTW: is anyone playing with this yet, in terms of code here? I might be interested if not...

tshinnic commented 7 years ago

BTW: also note the 'subset' font created for the text-rendering-tests at AdobeVFPrototype-Subset.otf Much smaller with only 3 glyphs defined. (7K vs 227K)

Yuck. These fonts (from Adobe and subset) have embedded everything to do with font variations, including the new 'blend' charstring operator which has a variable number of operands, depending on the number of variation 'regions' as defined in other sfnt tables (gdef, fvar, other ?var tables). Thus these two fonts require implementation of at least some of the variation-related tables and some of their data structures just to start on the CFF2 table itself. When you ask for 'CFF2' support you're kinda asking for the whole wad of "font variations" features. I'll start at it if no one says they're in-progress ...

But still asking - anyone know of any other fonts that have only the new CFF2 table without the helium inflated rubberized var tables?

brawer commented 7 years ago

I’m not aware of any non-variable CFF2 fonts; variations are are core part of the CFF2 format. (By the way, OpenType.js already supports the fvar table, but you’ll probably need to implement HVAR for CFF2 advance widths). Good luck!

devongovett commented 7 years ago

Just implemented CFF2 in fontkit. The format is not actually all that different from CFF1. Just a couple new operators, and a few things removed and moved to other existing tables (e.g. no more glyph names). The variation stuff is really the meat of it. If you're curious, here's the code: https://github.com/devongovett/fontkit/pull/88

Pomax commented 5 years ago

Bumping this issue becuase it's been 2 years since it got filed, and CFF2 is only getting more support, not less =)

Also note that CFF2 makes a whole heap of sense for non-fvar fonts, because it's even more compact than CFF, finally leaving all the metadata up to the opentype tables and only concerning itself with the glyphs themselves, similar to the glyf table, except with cubic curves and subroutines.

Connum commented 1 year ago

Started working on CFF2 support: https://github.com/opentypejs/opentype.js/tree/WIP/cff2