Decompose in Robofont
Ondrej Jób
Posts: 12
Hello typefolks!
I'm writing a script for FL and RF and I need to translate a glyph to SVG. I'm trying to find the best way to do this with a glyph with components and I have a problem with this sollutions:
if len(g.components): # if glyph has components
This method works great in FL, in RF however, it doesn't create a copy, but decomposes the glyph directly in the font. I tried to implement prepareUndo and performUndo methods, but they didn't seem to work. Do you have any tips on how I could make this work in RF?
I'm writing a script for FL and RF and I need to translate a glyph to SVG. I'm trying to find the best way to do this with a glyph with components and I have a problem with this sollutions:
if len(g.components): # if glyph has components
g = g.copy() # create a copy of it
g.decompose() # decompose it without affecting the original glyph# do stuff with the decomposed glyph
This method works great in FL, in RF however, it doesn't create a copy, but decomposes the glyph directly in the font. I tried to implement prepareUndo and performUndo methods, but they didn't seem to work. Do you have any tips on how I could make this work in RF?
0
Comments
-
Update: RF doesn't decompose the glyph, as @typemytype pointed out on Twitter, the copy cannot be decomposed because it doesn't have a parent font.0
-
it seems you need create a copy of font, then you can decompose any glyphs0
-
Yes, this is how I do it eventually: I add the copy as a new glyph to my font, decompose, do my stuff and then get rid of it. I was affraid this will make the script slower, but it didn't affect the performance at all.0
-
Seems like you could also use layers for this.
g.copyToLayer('copyLayer') gCopy = g.getLayer('copyLayer') gCopy.decompose() # do stuff with gCopy # and then when you're all done f.removeLayer('copyLayer')
If, for some reason, it worked better to do stuff in the foreground (so you could easily generate on-the-fly, for instance), you could decompose and do stuff to the glyph in the foreground, then at the end run a loop to swap your originals back into place.for g in f: g.flipLayers('foreground', 'copyLayer')
I don’t know if there’s any real performance advantage to using layers over making new dummy glyphs. Just seems more self-contained.0 -
Wouldn't it be easier to write a svg pen. Then you don't need to decompose anything.0
-
I’ve never used this, so I can’t vouch for the functionality, but Tal has a ufo2svg tool/library here:
https://github.com/typesupply/ufo2svg
(including a SVGPathPen)0
Categories
- All Categories
- 40 Introductions
- 3.7K Typeface Design
- 793 Font Technology
- 1K Technique and Theory
- 609 Type Business
- 443 Type Design Critiques
- 535 Type Design Software
- 30 Punchcutting
- 135 Lettering and Calligraphy
- 82 Technique and Theory
- 53 Lettering Critiques
- 478 Typography
- 300 History of Typography
- 113 Education
- 65 Resources
- 492 Announcements
- 78 Events
- 105 Job Postings
- 148 Type Releases
- 160 Miscellaneous News
- 269 About TypeDrawers
- 53 TypeDrawers Announcements
- 116 Suggestions and Bug Reports