Getting SVG path data for SVG Icon extension
This article will show you how to get the appropriate SVG path data for a vector shape created in Adobe Illustrator.
Open or create your shape in Adobe Illustrator
Make sure it is a compound path
When you select the shape Illustrator will tell you if it is a compound path. In this example, the shape is a Group. We need to convert this to a compound path first.
Object > Compound Path > Make
Use the Object > Compound Path > Make menu option to convert the shape to a compound path.
The shape is now a compound path.
Copy to clipboard
Now use Edit > Copy to copy the shape to the clipboard. Illustrator will copy the SVG data.
Get the d="..." data
Paste the clipboard into a text editing application. Then copy the d="" value.
Paste into iconPath field
In the SVG Icon inspector paste the path info into the iconPath property and press Enter. Your icon will then appear.
The SVG path data from Font Awesome needs to be flipped in order to be displayed correctly. The path data from Adobe Illustrator does not. Uncheck the flipped checkbox so that the icon displays correctly.
Great tutorial, Trevor.
You mention in the tutorial that SVG path data from Font Awesome needs to be flipped to be displayed correctly. I’m curious, how do you get the SVG path data from a Font Awesome character?
If you download Font Awesome from http://fortawesome.github.io/Font-Awesome/ you will find a fontawesome-webfont.svg file in the "fonts" folder in the distribution. That has the SVG paths for all of the fonts.
Nice, but how to do this with Inkscape, The data seems different, do i first to base64decode it? this is what is in the xml from Inkscape and when i import it base64decode or not i get an error: executing at 6:29:16 PM
LCB Error Unable to parse path data: "Path must begin with moveto command" at position 1
Object SVG Icon
LCB File svgpath.lcb
LCB Line 378
the image data in inkscape from an svg is: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAYAAACqNX6+AAAAAXNSR0IArs4c6QAAAARnQU1BAACx jwv8YQUAAAAJcEhZcwAAG64AABuuAYxdc/gAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAu OWwzfk4AAALFSURBVHhe7Zs9aBRBGIbPqGDjHwiCCP4Vkk6LYKWkUOyEKOIPiJVgIYKlgl4hYmUn 2IimEjwkt7N7RLDwmpDbmdsYTc6d2RMNVhYp1IgaNeb89vyMd5dRUtxNinsfeG/vdt/dYl5m5ht2 LgMAAAB0G35kNoly9ZCvzJlU6XdRer2ZLwNXBNGrw0Kap0LqnxRErVl6no4hHY+xHXSKwsTbjaJs Hi0OwS4K7V6tVuvh20E7GX5R3epLY2wN/z+JUF/hR4B2Qo17wpd6rrXBl6CZ4bC6jh8D2kkgkwGa G742NrhQ+gv1nE+N51olVHyUHwHaTVDW/RTCR5rQp2mOOJ7L5VZms9kerxSfpB5kmeRNLVDJZb4d dIK8rOx5PK63888FKKjntkCEMtfZAlwRRbXVFMg7WyA01J1jG3CFL+MbtjBoWPssShNYLLpEhPEp mlPSBaEtkKtsAy7wVHKQqqxvtjDo/JNisbiKraDTiNDsoMrqvT0MXfJG9Fq2AhdQoxesYShTyY9P bWAbcMFQabLXEkS6UJwtjCW9bAOu8MP4ki2QQJk7bAEuoZ5w0xaIJ+MBtgCXUOP3BeXkQqsKY2+2 sQWALseTLw9QpXXXD3UQqOTW0MjkLr4EXONJfX7R6lyaGa+c7GMLcAUt+LZQGLNNYfxVhW3AFULG Zy1BLKigkp1sBS6geeOiLYg/8lR1L1uBC0Q5TvdiWcOgoew73qE7Jn1tS73k2T8Cuc024JJ0W5BQ ZrQhiHkv1IP3i1Nr2AKWA0/p3UGU7E8rLz4FAABgGaDK5bSv9MNAGh9yJ6GSvB/G15peOaebkhvL R8i9hNKj9d369LGCysYPNhPkVvmS7s+kW2Wopv9hM0BuRWX8kd9DloyX/EcYqDOiUWo6F0Xr64Gk 22bo5IN062WrEeq09ByFoeh7Xz0MAAAAAAAAAADdTCbzC0a/fRTOechTAAAAAElFTkSuQmCC
is it not working becasue the original was an PNG and saved and re-opened as SVG ?
When you base64Decode that data it looks like it is still PNG data rather than an SVG path. This post suggests using the tracing option in Inkscape.
I hope that helps.
No, this does not work. Copied compound path in illustrator, nothing on clipboard.
I just did a quick test here and it seems to depend on the app you paste into. A plain text TextEdit document or Sublime Text worked for me. You could also Save As an SVG file from Illustrator, open the SVG file in a text editor and get the path data from there.
I hope that helps.
More often then not, when I paste the SVG data the icon becomes filled up.
For example a square that in illustrator has a black border and is transparent inside, in LC becomes all filled up with black.
Is there a way to avoid this?
Could you post an example path or send it to [email protected] so we can take a look.
I also sent an email with the Ai file.
The path is an open path of a small hand:
The SVG widget only supports filled paths. You can export an outline path from Adobe Illustrator by choosing
Object > Path > Outline Stroke
Then using Edit > Copy and pasting to the clipboard as in the lesson.
The path that is exported can be used in the SVG widget and appears as an outline.