Permalink
Browse files

Support drag and dropping SVG images as glyphs

  • Loading branch information...
santhoshtr committed Oct 14, 2017
1 parent 800c9b4 commit 08726cc26808ab47febca90aa0ce032c6be5d2b1
Showing with 11 additions and 0 deletions.
  1. +11 −0 Lib/trufont/controls/glyphCanvasView.py
@@ -6,6 +6,7 @@
from PyQt5.QtWidgets import QApplication
from defconQt.controls.glyphContextView import GlyphContextView, GlyphFlags
from defconQt.controls.glyphView import GlyphViewMinSizeForDetails
from fontTools.svgLib import SVGPath
from trufont.drawingTools.baseTool import BaseTool
from trufont.objects import settings
from trufont.objects.layoutManager import LayoutManager
@@ -321,6 +322,16 @@ def dropEvent(self, event):
ext = os.path.splitext(path)[1][1:]
# TODO: make sure we cleanup properly when replacing an image with
# another
if ext.lower() == "svg":
try:
svgPath = SVGPath.fromstring(data)
except Exception as e:
errorReports.showCriticalException(e)
return
self._glyph.beginUndoGroup()
svgPath.draw(self._glyph.getPen())
self._glyph.endUndoGroup()
return
if ext.lower() != "png":
# convert
img = QImage(path)

0 comments on commit 08726cc

Please sign in to comment.