Native Color layer: user color?

I had been working with SVG Layers, and am hoping to work with Glyphs’ native Color Layers (so it can export across a variety of formats). My standard workflow is to import external SVGs. I have a few questions around usage of colors in the Color layers that I am unable to find a solution in the docs nor forums. (“user-color” = what the user chooses as text-color in their applications.)

1a. How to specify a path to take user-color in the UI? (When I take a regular layer and convert it to Color, both stroke/fill are null and the path is not visible in the export.)
1b. How to specify a path to take user-color with scripts?


I markup SVGs with a fill="currentColor" attribute. Importing as SVG layers → exporting gives the expected behaviour (that these paths responds to user-color) but these are ignored in Color layers.

2. Is it possible to import from SVG and, based on a markup, specify a user-color? (In addition to being able to take currentColor, it would be very convenient to be able to convert paths that doesn’t have colors specified to this application foreground.)


  1. Is it possible now to use color indices in Color layers? (related to this question from a while ago) If not, is there a recommended way of importing SVGs and using color palettes?

Regards,
Jon

I believe currentColor does not work when embedded in a font.

Edit: Color Palette, not iColor.

If you want to export both SVG and COLR/CPAL, best to do an iColor Color Palette setup.

currentColor works in SVG import (into SVG layer), followed by export as OT-SVG.

I presume by iColor you mean the native Color layer; that is what all the questions in my original post pertains to. I just didn’t see any ways of working with user-color with Color (iColor?) layers.

Where does it work?

The spec says it should be supported but when I tried I could not get it to work in Adobe apps. Can you send me a sample SVG you are embedding that works in Illustrator?

Edit: Color Palette, not iColor.

No. The iColor Color Palette layers are the CPAL/COLR layers. The generic ‘Color’ layers are different:

image

Yes, Illustrator behaves very strangely with OT-SVG but it works on other applications. The same font export works with right dimensions and takes currentColor in Keynote, MS Word (on macOS), LibreOffice etc, but is both distorted and does not take currentColor:

image

I have attached an SVG of the same type here.

uniF0A0C.svg.zip (3.2 KB)


I cannot find out how to import SVG (scripting) into iColor layers, nor how to convert native Color layers into iColor layers. Advice?


(In general, I am getting the sense that it is not possible to work with user-colors in Glyphs. Is this correct?)

You would not import it to a Color layer, but into an SVG layer.

UPDATE: sorry, was confused myself. NOT iColor, but Color Palette. :person_facepalming: I edited my posts above accordingly.

And this is the Color Palette tutorial, for completeness:

What is currently not supported in SVG conversion, is the ‘asterisk color’, which is the user color. Should be converted to currentColor.

Otherwise, import the SVG directly in a svg layer:

(See ‘option A’)

Thanks — I understand that import-export works with the SVG layer. It was long previous conversations with Georg that suggests I should be working with Color layers; which does work better in the export when the sizes of the images are irregular.

SVG Import → SVG layer → SVG export

Keynote (notice the light green on the first structure; that’s the currentColor):

Illustrator:

SVG Import → Color layer → SVG export

Keynote:

Illustrator

SVG Import → convert manually to Color Palette layer → SVG export
Keynote

Illustrator

This looks exactly the same as the SVG export.


I don’t know why they should be different, but clearly only importing into a Color layer gives the right output when exported. However, that loses any ability to set user-color / asterisk color. Is there a way around that?

[Edit: I can set the currentColor, by using fonttools to bust open the ttf → ttx, and text-editing the SVGs to add fill=“currentColor”:

But needless to say, I’d far prefer a less low-level solution, and this method doesn’t export to other color formats, negating one of the supposed advantages of using Color layer. These currentColor tags are removed the moment it’s passed through Color; if they can just be preserved, that would do the trick.]

I’ll put that on the list. One of the issues is that the Color layer supports a lot more than can be exported into SVG or CPAL/COLR fonts. And currently there is no such thing as ‘user-set color’ (or the SVG currentColor) implemented yet.

1 Like

Thanks for confirming the limits. I am enthusiastic about pushing the limits of color fonts (e.g., the released SIL 1.1 Cantonese Font at www.visual-fonts.com), and would be happy to be sounding board / tester.

The Color Palette layers do support the “current color” by selecting the “*” in the color selection popup.

The full color layers can’t handle that at the moment. I’ll see what we can do.

I see

  • Fix “currentColor” for svg from color layers

in the Changelog (for 3209; 2023-08-10), so I think there may have been an attempt at solving this. However, the current behaviour (3227), when importing an SVG, remains that the path carrying fill="currentColor" attribute are imported as no-fill no-stroke, and exports to SVG font as invisible (and not accepting application color).

(Or perhaps that fix was for something else?)

The fix was for the output. I’ll have a look at the input.

Is there movement in making * asterix color available for Color layers, at the import stage, or assigning through scripting?

You can already assign it with a script.

Layer.attributes["colorPalette"] = "*"

I’ll check the import

I think you’re talking about Color Palette layers, instead of the native Color layers?

But your tip was timely; in continuing my effort to expand the export from OT-SVG (and improve compatibility), I split the native Color layer into Color Palette layers (thanks to gracious sharing of @michaelrafailyk :man_bowing:). Something goes wrong with htmx/vtmx/colr tables when Glyphs export COLR above certain number of color glyphs (the CJK font I’m working with has ~30,000 five-colored glyphs); I’ll do more tests, prepare some comparison files, and present them to Support inbox.

A font can only have 65000 glyphs. COLR fonts will decompose each ‘Color X’ layer into its own glyphs. If you have two color per glyph, that results in 60000 extra glyphs. Together 90000 and clearly over the limit.

2 Likes

Thank you Georg. Alas, I keep bumping up to the 65k limit…