Inkscape.org
Using Inkscape with Other Programs "fill" vs "style=fill"
  1. #1
    below below @below
    *

    Hello,

    for an iOS app, I am trying to change the color in an existing file. This file uses `fill=#00bb00` to specify colors.

    When I edit the file with Inkscape, this attribute still persists, and a new attribute is added: `style="fill:#ff0000`.

    Browsers and the macOS finder see this `style` attribute, but neither Xcode not the iOS or macOS SDKs do.

    Is there a way I can tell Inkscape to use the `fill` attribute?

    A full description of the issue can be found here: https://github.com/below/SVGSample

    Thanks for you help!

  2. #2
    Tyler Durden Tyler Durden @TylerDurden

    In a related topic, style info was converted to inline (opposite of your situation). https://inkscape.org/forums/questions/svgs-import-but-dont-display-correctlyfully/

    You could ask in that topic if a reverse method could be created, converting the inline style info into separate attributes (referring back to this topic).

  3. #3
    Aero Aero @Aero◻️

    Convert CSS attributes to XML attributes is an option in save as optimised SVG.

  4. #4
    below below @below

    One thing that sounds like a bug: While Inkscape reads the XML attribute, it does not change it, and just adds the CSS attribute with a different color.

    This results in two different colors for the same object, making the color dependent on the order of preference a renderer assigns to these 

  5. #5
    inklinea inklinea @inklinea⛰️

    Following on to Aeros post

    It might be an idea to try this first 

    https://jakearchibald.github.io/svgomg/

    Which is a front end (can be run locally too) for https://github.com/svg/svgo

  6. #6
    Tyler Durden Tyler Durden @TylerDurden

    Brute force methods.

    For a single object:

    • Copy object, paste> style to same object. This will write style info into a style element.
    • Save document(s)
    • Open documents in text editor (eg Notepad++) and delete all fill, stroke elements using wildcard search/replace.

     

    For multiple objects, just fill and stroke rewriting:

    • Open in Inkscape
    • Select all in all layers
    • Extensions>Color>HSL adjust, click ok (To run with no values adjusted. This will write current fill/stroke values into a style element)
    • Save document
    • Repeat for all documents
    • Open documents in text editor (eg Notepad++) and delete all fill, stroke elements using wildcard search/replace.