nfroidure / svgfont2svgicons

Extract SVG icons from an SVG font
MIT License
15 stars 10 forks source link

Options suggestion #8

Open mm-tom opened 8 years ago

mm-tom commented 8 years ago

You mention suggestions for options are welcome, so here goes...

It would be really handy to be able to pass in a set of attributes to apply to the svg node.

In my instance, I'd like to be able to set the id and also perhaps store some other information in arbitrary attributes.

nfroidure commented 8 years ago

You mean adding attributes to the outputted SVG iconsfrom font glyphs ?

If so, an option like option.attributesMapproviding a an objet to map source SVG font glyphs attributes to the corresponding SVG icon element could make the job.

Something like:

svgfont2svgicons({
  attributesMap: {
    'target-id' : 'id',
    'metadata' : 'metadata',
  },
});

On the other side, doing SVG manipulations would better sit in a different module imo (separation of concerns etc.).

Edit: s/svgicons2svgfont/svgfont2svgicons/ ;)

mm-tom commented 8 years ago

Yes, exactly that.

My slight issue is that my svg font doesn't contain the attributes either, but I do have them to hand.

I'll fork and try to add something in myself. Maybe something separate would be cleaner.

nfroidure commented 8 years ago

In case you write a separate module, feel free to PR the README to claim its existence.