Pomax / lib-font

This library adds a new Font() object to the JavaScript toolbox, similar to new Image() for images
MIT License
728 stars 72 forks source link

Color font info #126

Open o-t-w opened 2 years ago

o-t-w commented 2 years ago

I opened this issue on a project that uses this as a dependency. Is it possible to grab this info using lib-font?

In the CSS fonts Level 4 spec, base-palette can reference a named color-palette embedded inside the font. Can lib-font obtain that information?

override-colors can reference different layers of the font either using a numerical index, or named indexes. Can lib-font get the names of these layers? https://github.com/Wakamai-Fondue/wakamai-fondue-site/issues/147

Pomax commented 2 years ago

the COLR table format 0 is supported, in the sense that you can query the table and then use its data to find the CPAL entries for glyphs. Get the a glyph's BaseGlyphRecord, then find its record.numLayers associated layers starting at record.firstLayerIndex. Each layer has a glyph id that should match the one you're working with (useful for error detection) and a paletteIndex value that is used with the CPAL table

The just-accepted COLR table format 1 does not have a code backing at present, so a lot of the color-related parts of the in-draft CSS4 spec are unlikely to currently work with this library.