Skip to content

Commit

Permalink
Draft - enabled utf8 in coin3d and svg - relates to issue #1404
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Mar 29, 2014
1 parent 8693bfa commit 749a8fa
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/Mod/Draft/Draft.py
Expand Up @@ -670,7 +670,7 @@ def makeDimension(p1,p2,p3=None,p4=None):
obj.ViewObject.Override = "R $dim"
elif p3 == "diameter":
l.append((p1,"Diameter"))
obj.ViewObject.Override = "D $dim"
obj.ViewObject.Override = "Ø $dim"
obj.LinkedGeometry = l
obj.Support = p1
p3 = p4
Expand Down Expand Up @@ -876,8 +876,11 @@ def makeText(stringslist,point=Vector(0,0,0),screen=False):
if not isinstance(stringslist,list): stringslist = [stringslist]
textbuffer = []
for l in stringslist:
#textbuffer.append(l.decode("utf8").encode('latin1'))
textbuffer.append(str(l))
try:
# only available in Coin3D >= 4.0
textbuffer.append(str(l))
except:
textbuffer.append(l.decode("utf8").encode('latin1'))
obj=FreeCAD.ActiveDocument.addObject("App::Annotation","Text")
obj.LabelText=textbuffer
obj.Position=point
Expand Down Expand Up @@ -1706,7 +1709,10 @@ def getText(color,fontsize,fontname,angle,base,text):
svg += 'scale(1,-1) '
svg += '" freecad:skip="1"'
svg += '>\n'
svg += text
try:
svg += text
except:
svg += text.decode("utf8")
svg += '</text>\n'
return svg

Expand Down Expand Up @@ -1840,8 +1846,8 @@ def getText(color,fontsize,fontname,angle,base,text):
svg += 'font-family:'+obj.ViewObject.FontName+'" '
svg += 'transform="'
if obj.ViewObject.RotationAxis == 'Z':
if obj.ViewObject.Rotation != 0:
svg += 'rotate('+str(obj.ViewObject.Rotation)
if obj.ViewObject.Rotation.getValueAs("deg") != 0:
svg += 'rotate('+str(obj.ViewObject.Rotation.getValueAs("deg"))
svg += ','+ str(p.x) + ',' + str(p.y) + ') '
svg += 'translate(' + str(p.x) + ',' + str(p.y) + ') '
#svg +='scale('+str(tmod/2000)+','+str(-tmod/2000)+')'
Expand Down Expand Up @@ -3182,7 +3188,11 @@ def updateData(self, obj, prop):
fstring = "%." + str(getParam("dimPrecision",2)) + "f"
self.string = (fstring % l)
if obj.ViewObject.Override:
self.string = unicode(obj.ViewObject.Override).encode("latin1").replace("$dim",self.string)
try:
# only available in Coin3D >= 4.0
self.string = obj.ViewObject.Override.encode("utf8").replace("$dim",self.string)
except:
self.string = unicode(obj.ViewObject.Override).encode("latin1").replace("$dim",self.string)
self.text.string = self.text3d.string = self.string

# set the distance property
Expand Down

0 comments on commit 749a8fa

Please sign in to comment.