Hi,
I saw this program.
I want to import multiple svg files at once to the layer that I can edit.
I can’t work like this.
pickpath = GetFolder("Please choose a folder with images")
pickextension = "svg"
masterID = Glyphs.font.masters[Glyphs.font.masterIndex].id
for glyph in Glyphs.font.glyphs:
if glyph.unicode:
print glyph.unicode
layer = glyph.layers[masterID]
layer.path = GSPath(pickpath + glyph.unicode + '.' + pickextension) #What should be expressed here?
1 Like
more like this:
GSSVGtoPath = NSClassFromString("GSSVGtoPath")
path = "/path/to/file.svg"
Importer = GSSVGtoPath.alloc().init()
Importer.readFile_toLayer_error_(NSURL.fileURLWithPath_(path), Layer, None)
2 Likes
That’s great! Thank you very much!
lena.weber
(Lena Weber)
November 3, 2021, 2:23pm
4
I also want to use multiple svg’s on a single svg layer, but I’m having trouble using this code, as it’s my first time working with the “makro window”.
I replaced the generic path with the path to the svg I want to use, is there something else I need to replace?
I get:
Traceback (most recent call last):
File "<macro>", line 4, in <module>
ValueError: NSInvalidArgumentException - -[NSXMLNode stringValueForName:]: unrecognized selector sent to instance 0x600006643da0
mekkablue
(Rainer Erich Scheichelbauer)
November 4, 2021, 6:57am
5
Are you sure it’s a valid SVG? This error says that it cannot read the XML.
lena.weber
(Lena Weber)
November 4, 2021, 10:43am
6
Thank you for your quick reply!
I was quite sure, It’s a black to white gradient created with Adobe Illustrator:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 301 302">
preserveAspectRatio="none"
<defs>
<style>
.a {
fill: url(#a);
}
</style>
<linearGradient id="a" data-name="v" x1="-0.5" y1="150" x2="301.5" y2="150" gradientTransform="translate(0.5 301.5) rotate(-90)" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#fff"/>
<stop offset="1"/>
</linearGradient>
</defs>
<rect class="a" width="301" height="302"/>
</svg>
What makes an SVG invalid to be used within Glyphs?
The script works fine for me. What versions of Glyphs and macOS of you have?
lena.weber
(Lena Weber)
November 5, 2021, 3:55pm
8
tried it on glyphs Version 2.6.7 (1357)
and
macOS Big Sur 11.6
This particular has a line that seems odd. Remove preserveAspectRatio="none"
.