Commit 5a084d6c authored by sumpfralle's avatar sumpfralle

improved unicode handling for CXF fonts


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@863 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent d1174da1
......@@ -1670,6 +1670,7 @@ class ProjectGui:
text_buffer = input_field.get_buffer()
text = text_buffer.get_text(text_buffer.get_start_iter(),
text_buffer.get_end_iter())
text = unicode(text)
if text:
skew = self.gui.get_object("FontSideSkewValue").get_value()
line_space = self.gui.get_object("FontLineSpacingValue").get_value()
......
......@@ -104,11 +104,19 @@ class CXFParser(object):
elif line.startswith("["):
# Update the GUI from time to time.
# This is useful for the big unicode font.
if self.callback and (len(self.letters) % 100 == 0):
if self.callback and (len(self.letters) % 50 == 0):
self.callback()
if (len(line) >= 3) and (line[2] == "]"):
# single character
character = line[1]
for encoding in ("utf-8", "iso8859-1", "iso8859-15"):
try:
character = unicode(line[1], encoding)
break
except UnicodeDecodeError:
pass
else:
raise _CXFParseError("Failed to decode character at " \
+ "line %d" % feeder.get_index())
elif (len(line) >= 6) and (line[5] == "]"):
# unicode character (e.g. "[1ae4]")
try:
......@@ -120,7 +128,7 @@ class CXFParser(object):
# read UTF8 (qcad 1 compatibility)
end_bracket = line.find("] ")
text = line[1:end_bracket]
character = text.decode("utf-8")[0]
character = unicode(text, "utf-8")[0]
else:
# unknown format
raise _CXFParseError("Failed to parse character at line " \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment