Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for Multi-Colored SVG Icons #675

Closed
ryangwilson opened this issue Nov 28, 2018 · 3 comments
Closed

Allow for Multi-Colored SVG Icons #675

ryangwilson opened this issue Nov 28, 2018 · 3 comments

Comments

@ryangwilson
Copy link

We have a need for multiple colors to be included/embedded in SVGs in out icon sets. This is easily done in IcoMoon, but is a shortcoming of Fontello.

icon-compare

In IcoMoon we can touch internal paths, e.g.:

.icon-sun-happy .path1:before {
  content: "\e900";
  color: rgb(255, 204, 51);
}
.icon-sun-happy .path2:before {
  content: "\e901";
  margin-left: -1em;
  color: rgb(255, 102, 0);
}
.icon-sun-happy .path3:before {
  content: "\e902";
  margin-left: -1em;
  color: rgb(255, 102, 0);
}
.icon-sun-happy .path4:before {
  content: "\e903";
  margin-left: -1em;
  color: rgb(255, 102, 0);
}
@Dreamersoul
Copy link

Fonts are not meant to include colors if I recall correctly. I usually just apply a CSS color property to color the font

@puzrin
Copy link
Member

puzrin commented May 20, 2020

As been said - this job is for CSS, not related to fontello.

@puzrin puzrin closed this as completed May 20, 2020
@hansmbakker
Copy link

hansmbakker commented Oct 18, 2023

Hi @puzrin, can you please reopen this issue?

The point is that multi-colored SVGs need to be split into multiple glyphs that can be rendered on top of each other.

  • The coloring can indeed be done by CSS
  • However, the splitting is something that can be done by Fontello
  • Also, it would be helpful if Fontello would generate the CSS to stack the glyphs and color them like IcoMoon does:

Font glyphs cannot have more than one color by default. Using CSS, IcoMoon stacks multiple glyphs on top of each other to implement multicolor glyphs. As a result, these glyphs take more than one character code and cannot have ligatures.

Using this SVG: Account circle duotone.svg, IcoMoon understands it is a multi-colored SVG that needs to be split into multiple following glyphs, and it generates the required CSS to color those glyphs and stack them on top of each other:

.icon-Account-circle-duotone .path1:before {
  content: "\e900";
  color: rgb(86, 134, 225);
  opacity: 0.3;
}
.icon-Account-circle-duotone .path2:before {
  content: "\e901";
  margin-left: -1em;
  color: rgb(86, 134, 225);
}
image

It creates a \e900 glyph for the background and a \e901 glyph for the foreground.

This is also how FontAwesome works: https://blog.pieeatingninjas.be/2022/12/13/fontawesome-duotone-icons-in-maui-and-xamarin-forms/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants