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.)
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?
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.
iColor Color Palette layers are the CPAL/COLR layers. The generic ‘Color’ layers are different:
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
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. 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):
SVG Import → Color layer → SVG export
SVG Import → convert manually to Color Palette layer → SVG export
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.
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.
- 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.