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

SVG Rendering issues #1

Open
aloisdeniel opened this issue Nov 22, 2020 · 2 comments
Open

SVG Rendering issues #1

aloisdeniel opened this issue Nov 22, 2020 · 2 comments
Labels
question Further information is requested

Comments

@aloisdeniel
Copy link
Owner

aloisdeniel commented Nov 22, 2020

If you have a rendering issue with an icon, please share its data content here.

Remember that the parsing pass is basic, on purpose. So make sure your vector data is really simple, composed only of filled shapes.

The only supported operations and properties are :

  • circle : cx, cy, r
  • ellipse : cx, cy, rx, ry
  • rect : x, y, width, height
  • path : d, fill-rule
  • g : transform

All paths from operations are merged as a single path, filled with a unique color.

Preparing an icon in Figma

Outlining strokes

Let's take an example :

image

By default, Figma exports it to :

<svg width="155" height="148" viewBox="0 0 155 148" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M57.3785 ... 120.434Z" fill="black"/>
<circle cx="118.947" cy="73.5258" r="29.2399" stroke="black" stroke-width="13.6264"/>
</svg>

This won't work, since the circle is drawn with a stroke.

Right click on the circle, and choose Outline strokes from the menu.

image

image

The SVG now looks fine :

<svg width="155" height="148" viewBox="0 0 155 148" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M57.3785 .. 120.434Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M118.947 ...109.579Z" fill="black"/>
</svg>

Flattening

If you use complexe operations in your designing software (like unions/intersects), flattening the shapes may improve the final export.

For example :

image

The export may sometimes work, but it is generally better to have raw flatten path. To flatten your shapes, right-click on the shape, and select Flatten.

image

That's it ! You now have a unique path.

image

Optimizing data before release

If you want to optimize a bit the parsing before your production release, you can remove all the unnecessary properties.

<svg  viewBox="0 0 155 148">
<path fill-rule="evenodd"  d="M57.3785 .. 120.434Z" />
<path fill-rule="evenodd"  d="M118.947 ...109.579Z" />
</svg>

If you want an even more optimized parsing pass, you can join multiple path together, get a unique data content and use the PathIconData.fromData instead.

M57.3785 .. 120.434Z M118.947 ...109.579Z
@aloisdeniel aloisdeniel added the question Further information is requested label Nov 22, 2020
@aloisdeniel aloisdeniel changed the title Rendering issues SVG Rendering issues Nov 22, 2020
@SergioEric
Copy link

Thanks, this was very useful, Will be better to put this in readme!

@aloisdeniel
Copy link
Owner Author

Added a warning with a link to it !

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

No branches or pull requests

2 participants