Permalink
Browse files

Support pasting SVG from clipboard

v2
  • Loading branch information...
santhoshtr authored and adrientetar committed Oct 14, 2017
1 parent ff1c100 commit 78109b2a004cadaeb4a247c3330d69bdb2311c71
Showing with 15 additions and 0 deletions.
  1. +15 −0 Lib/trufont/windows/fontWindow.py
@@ -6,6 +6,7 @@
from defconQt.controls.glyphCellView import GlyphCellView
from defconQt.windows.baseWindows import BaseWindow
from fontTools.feaLib.error import FeatureLibError
from fontTools.svgLib import SVGPath
from trufont.controls.exportDialog import ExportDialog
from trufont.controls.fileMessageBoxes import CloseMessageBox, ReloadMessageBox
from trufont.controls.fontDialogs import AddGlyphsDialog, SortDialog
@@ -743,6 +744,20 @@ def paste(self):
glyph.endUndoGroup()
else:
glyph.deserialize(pickled)
elif mimeData.hasFormat("image/svg+xml"):
if len(glyphs) == 1:
glyph = glyphs[0]
try:
svgPath = SVGPath.fromstring(
mimeData.data("image/svg+xml"))
except Exception as e:
raise ValueError(
"SVG Paste error: {}".format(str(e)))

This comment has been minimized.

Show comment
Hide comment
@khaledhosny

khaledhosny Oct 14, 2017

Contributor

Isn’t raising an exception here too much? I’d rather just ignore this format and continue trying others.

@khaledhosny

khaledhosny Oct 14, 2017

Contributor

Isn’t raising an exception here too much? I’d rather just ignore this format and continue trying others.

This comment has been minimized.

Show comment
Hide comment
@adrientetar
@adrientetar
glyph.beginUndoGroup()
if not isGlyphTab:
glyph.clear()
svgPath.draw(glyph.getPen())
glyph.endUndoGroup()
elif mimeData.hasText():
if len(glyphs) == 1:
glyph = glyphs[0]

0 comments on commit 78109b2

Please sign in to comment.