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

Add support for openType SVG color fonts

Open Mottie opened this issue 9 years ago • 13 comments
trafficstars

It looks like Microsoft is adopting the openType SVG color fonts format, so adding support for the SVG colr and cpal objects would be necessary.

I was trying to see if I could figure it out myself, but I am just now learning how to process ArrayBuffer objects and DataViews. That combined with figuring out an unfamiliar code base would take me a long time. I won't stop trying to learn, and I'll still work on adding this feature in my free time, unless someone beats me to it.

Useful links:

Mottie avatar Jun 13 '16 00:06 Mottie

I believe this is required for opentype.js to support emoji fonts.

mqudsi avatar May 04 '17 15:05 mqudsi

@mqudsi Yes but actually it depends on the platform as Google's emojis are in CBDT CBLC tables, Microsoft's COLR CPAL, Apple's sbix

Jolg42 avatar May 04 '17 15:05 Jolg42

Supporting a single standard is a whole lot better than not supporting any of them. As a first step I would suggest having the forEachGlyph function to return information about what character it can't render allowing things like emojis to be handled as exceptions in user code rather than returning glyph 0.

talltyler avatar Jun 12 '17 21:06 talltyler

@talltyler the problem you're describing needs to be fixed, check the issue https://github.com/nodebox/opentype.js/issues/168 for more info

Jolg42 avatar Jun 14 '17 07:06 Jolg42

I've addressed first issue in #297. The next issue has a few parts. We can only render vector paths. Color also isn't currently managed within the core code. If we are supporting bitmap fonts we should maybe talk about what other things we want to support. Also should we talk about how fallbacks fonts should work. After looking at these different table types, personally I don't like sbix as much as the other two. But adopting full SVG support has a few issues https://connect.microsoft.com/IE/feedback/details/809823/draw-svg-image-on-canvas-context but I also wonder what kind of browser support this library is trying to hit? If we don't think SVG is going to fly sticking with one of the bitmap focused formats might be best. Also SVG animation wouldn't be able to be supported unless we made a svg parser and managed all of this in code.

talltyler avatar Jun 16 '17 18:06 talltyler

Is this the issue why I get a "Error: Font doesn't contain TrueType or CFF outlines" message when uploading "Noto Color Emoji" font (google.com/get/noto/#emoji-zsye-color)?

JanisE avatar Mar 13 '18 20:03 JanisE

@talltyler I somehow missed your comment, and you raise some very good questions. Font rendering was never easy, but now it's become a whole new level of complicated. But I think the goal behind the adoption of SVG and not a new vector/path markup language is to enable developers in need of rendering glyphs and symbols like this to make use of already existing, battle-tested libraries instead of needing to reinvent the wheel. I'd argue that the creators of the OpenType standard would probably be aghast to discover people thought it meant they had to write their own SVG parser and animation library to support these new features. 😉

mqudsi avatar Mar 13 '18 22:03 mqudsi

FYI this is a highly requested feature over at Glyphr Studio. This, plus supporting Non-BMP ranges (which was fixed in #338) is crucial to supporting emojis... which people seem to be interested in at the moment :-D

mattlag avatar Sep 10 '18 17:09 mattlag

COLR/CPAL +1

yisibl avatar Feb 01 '21 13:02 yisibl

Add COLRv0 + CPALv0 support in : https://github.com/opentypejs/opentype.js/pull/490

yisibl avatar Oct 20 '21 06:10 yisibl

As far as I can see, merging #490 should have closed this issue, right? Any objections?

Connum avatar Feb 17 '23 10:02 Connum

SVG fonts are not the same as color fonts. The SVG table is mac specific, we should support it and the other methods of rendering emoji.

ILOVEPIE avatar Feb 17 '23 20:02 ILOVEPIE

Microsoft is not adopting the SVG table btw, only apple.

ILOVEPIE avatar Feb 21 '23 03:02 ILOVEPIE

SVG and COLR/CPAL are both now supported.

Connum avatar Apr 21 '24 09:04 Connum