Skip to content

Commit 9b93630

Browse files
committed
Improve reading sources while exporting to svg.
fixing #54
1 parent a273ae7 commit 9b93630

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

Batch.roboFontExt/lib/webFormats/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def convertToEot(ttfPath, dest):
167167

168168

169169
def convertToSVG(ttfPath, dest):
170-
SVGBuilder(ttfPath, dest)
170+
return SVGBuilder(ttfPath, dest)
171171

172172

173173
htmlPreviewDefault = string.ascii_letters + string.digits
@@ -478,7 +478,11 @@ def _convertPath(self, path, destDir, saveOTF=True, saveTTF=True, saveWOFF=True,
478478
report.indent()
479479
report.write("path: %s" % svgPath)
480480
buildTree(fontDir)
481-
convertToSVG(path, svgPath)
481+
message = convertToSVG(path, svgPath)
482+
if message:
483+
report.indent()
484+
report.write(message)
485+
report.dedent()
482486
report.dedent()
483487
report.newLine()
484488

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from ufo2svg import convertUFOToSVGFont
22
from defcon import Font
33
from extractor import extractUFO
4+
from fontTools.ufoLib.errors import UFOLibError
45

56

67
def generateSVG(source, dest):
7-
font = Font()
88
try:
9+
font = Font(source)
10+
except UFOLibError:
11+
font = Font()
912
extractUFO(source, font)
13+
except Exception as e:
14+
return f"Failed to extract path {source}: {e}."
15+
16+
try:
1017
convertUFOToSVGFont(font, dest)
11-
except Exception:
12-
return ("Failed to generate SVG.", "")
13-
return ("", "")
18+
except Exception as e:
19+
return f"Failed to generate SVG: {e}."
20+
return ""
1421

1522

1623
def SVGBuilder(sourcePath, destinationPath):
17-
generateSVG(sourcePath, destinationPath)
24+
return generateSVG(sourcePath, destinationPath)

0 commit comments

Comments
 (0)