[Techdraw] Import SVG files with UTF-8 encoding (#18816)
* [Techdraw] Fix importing SVG files with UTF-8 encoding * [Techdraw] fix Lint feedback
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
import FreeCAD
|
||||
import codecs
|
||||
import os
|
||||
import unittest
|
||||
from .TechDrawTestUtilities import createPageWithSVGTemplate
|
||||
@@ -21,7 +22,26 @@ class DrawViewSymbolTest(unittest.TestCase):
|
||||
sym = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewSymbol", "TestSymbol")
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
symbolFileSpec = path + "/TestSymbol.svg"
|
||||
f = open(symbolFileSpec, "r")
|
||||
f = codecs.open(symbolFileSpec, "r", encoding="utf-8")
|
||||
svg = f.read()
|
||||
f.close()
|
||||
sym.Symbol = svg
|
||||
self.page.addView(sym)
|
||||
sym.X = 220.0
|
||||
sym.Y = 150.0
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
self.assertTrue("Up-to-date" in sym.State)
|
||||
|
||||
def testNonAsciiSymbol(self):
|
||||
"""Tests if a Non-Ascii symbol can be added to page"""
|
||||
sym = FreeCAD.ActiveDocument.addObject(
|
||||
"TechDraw::DrawViewSymbol", "NonAsciiSymbol"
|
||||
)
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
symbolFileSpec = path + "/TestNonAsciiSymbol.svg"
|
||||
f = codecs.open(symbolFileSpec, "r", encoding="utf-8")
|
||||
svg = f.read()
|
||||
f.close()
|
||||
sym.Symbol = svg
|
||||
@@ -34,5 +54,6 @@ class DrawViewSymbolTest(unittest.TestCase):
|
||||
self.assertTrue("Up-to-date" in sym.State)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user