Arch/Draft: Fixed py3 bugs in text rendering
This commit is contained in:
@@ -148,7 +148,7 @@ ConditioningTypes = [
|
||||
"NaturallyVentedOnly"
|
||||
]
|
||||
|
||||
import FreeCAD,ArchComponent,ArchCommands,math,Draft
|
||||
import FreeCAD,ArchComponent,ArchCommands,math,Draft,sys
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
from PySide import QtCore, QtGui
|
||||
@@ -609,10 +609,12 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
t = t.replace("$walls",vobj.Object.FinishWalls)
|
||||
if hasattr(vobj.Object,"FinishCeiling"):
|
||||
t = t.replace("$ceiling",vobj.Object.FinishCeiling)
|
||||
if sys.version_info.major < 3:
|
||||
t = t.encode("utf8")
|
||||
if first:
|
||||
text1.append(t.encode("utf8"))
|
||||
text1.append(t)
|
||||
else:
|
||||
text2.append(t.encode("utf8"))
|
||||
text2.append(t)
|
||||
first = False
|
||||
if text1:
|
||||
self.text1.string.setValues(text1)
|
||||
|
||||
@@ -7368,8 +7368,12 @@ class ViewProviderDraftText:
|
||||
def updateData(self,obj,prop):
|
||||
if prop == "Text":
|
||||
if obj.Text:
|
||||
self.text2d.string.setValues([l.encode("utf8") for l in obj.Text if l])
|
||||
self.text3d.string.setValues([l.encode("utf8") for l in obj.Text if l])
|
||||
if sys.version_info.major >= 3:
|
||||
self.text2d.string.setValues([l for l in obj.Text if l])
|
||||
self.text3d.string.setValues([l for l in obj.Text if l])
|
||||
else:
|
||||
self.text2d.string.setValues([l.encode("utf8") for l in obj.Text if l])
|
||||
self.text3d.string.setValues([l.encode("utf8") for l in obj.Text if l])
|
||||
elif prop == "Placement":
|
||||
self.trans.translation.setValue(obj.Placement.Base)
|
||||
self.trans.rotation.setValue(obj.Placement.Rotation.Q)
|
||||
@@ -7388,15 +7392,18 @@ class ViewProviderDraftText:
|
||||
elif prop == "Justification":
|
||||
if "Justification" in vobj.PropertiesList:
|
||||
from pivy import coin
|
||||
if vobj.Justification == "Left":
|
||||
self.text2d.justification = coin.SoText2.LEFT
|
||||
self.text3d.justification = coin.SoAsciiText.LEFT
|
||||
elif vobj.Justification == "Right":
|
||||
self.text2d.justification = coin.SoText2.RIGHT
|
||||
self.text3d.justification = coin.SoAsciiText.RIGHT
|
||||
else:
|
||||
self.text2d.justification = coin.SoText2.CENTER
|
||||
self.text3d.justification = coin.SoAsciiText.CENTER
|
||||
try:
|
||||
if vobj.Justification == "Left":
|
||||
self.text2d.justification = coin.SoText2.LEFT
|
||||
self.text3d.justification = coin.SoAsciiText.LEFT
|
||||
elif vobj.Justification == "Right":
|
||||
self.text2d.justification = coin.SoText2.RIGHT
|
||||
self.text3d.justification = coin.SoAsciiText.RIGHT
|
||||
else:
|
||||
self.text2d.justification = coin.SoText2.CENTER
|
||||
self.text3d.justification = coin.SoAsciiText.CENTER
|
||||
except AssertionError:
|
||||
pass # Race condition - Justification enum has not been set yet
|
||||
elif prop == "LineSpacing":
|
||||
if "LineSpacing" in vobj.PropertiesList:
|
||||
self.text2d.spacing = vobj.LineSpacing
|
||||
|
||||
@@ -1822,7 +1822,9 @@ class Text(Creator):
|
||||
tx += ','
|
||||
if sys.version_info.major < 3:
|
||||
l = unicode(l)
|
||||
tx += '"'+str(l.encode("utf8"))+'"' #Python3 no more unicode
|
||||
tx += '"'+str(l.encode("utf8"))+'"'
|
||||
else:
|
||||
tx += '"'+l+'"' #Python3 no more unicode
|
||||
tx += ']'
|
||||
FreeCADGui.addModule("Draft")
|
||||
self.commit(translate("draft","Create Text"),
|
||||
|
||||
Reference in New Issue
Block a user