Skip to content

Commit

Permalink
python3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Jul 7, 2016
1 parent 67ce5b1 commit 944ac57
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Binary file modified python2-scripts.zip
Binary file not shown.
10 changes: 4 additions & 6 deletions python2-scripts/mcpipy/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ def drawGlyph(mc, pos, forwardVec, upVec, glyph, foreground, background=None):

def drawText(mc, font, pos, forwardVec, upVec, text, foreground, background=None):
try:
text = text.decode("cp1252")
text = bytearray(text.encode("cp1252"))
except:
text = text.decode("iso8859_1")
text = bytearray(text.encode("iso8859_1"))
pixelPos = pos.clone()
height = len(font[32][3])
numLines = text.count("\n")+1
numLines = text.count(b'\n')+1
pixelPos += upVec * ((numLines-1) * height)
lineStart = pixelPos.clone()
for c in text:
value = ord(c)

for value in text:
if value == 10:
lineStart += upVec * (-height)
pixelPos = lineStart.clone()
Expand Down
Binary file modified python3-scripts.zip
Binary file not shown.
10 changes: 4 additions & 6 deletions python3-scripts/mcpipy/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ def drawGlyph(mc, pos, forwardVec, upVec, glyph, foreground, background=None):

def drawText(mc, font, pos, forwardVec, upVec, text, foreground, background=None):
try:
text = text.decode("cp1252")
text = bytearray(text.encode("cp1252"))
except:
text = text.decode("iso8859_1")
text = bytearray(text.encode("iso8859_1"))
pixelPos = pos.clone()
height = len(font[32][3])
numLines = text.count("\n")+1
numLines = text.count(b'\n')+1
pixelPos += upVec * ((numLines-1) * height)
lineStart = pixelPos.clone()
for c in text:
value = ord(c)

for value in text:
if value == 10:
lineStart += upVec * (-height)
pixelPos = lineStart.clone()
Expand Down

0 comments on commit 944ac57

Please sign in to comment.