From 974bf6697e3a9d54b5838a9f87d78b3fb9e74015 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 22 Jan 2015 20:48:48 +0100 Subject: png2bdc.py: Converted to python 2.5 syntax. (nw) --- src/build/png2bdc.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/build/png2bdc.py b/src/build/png2bdc.py index 7d4d7df5d3e..03172654b25 100644 --- a/src/build/png2bdc.py +++ b/src/build/png2bdc.py @@ -116,27 +116,29 @@ def renderFontSaveCached(font, filename, hash32): CACHED_CHAR_SIZE = 12 CACHED_HEADER_SIZE = 16 - try: + #try: + if 0 == 0: fp.write('f') fp.write('o') fp.write('n') fp.write('t') - fp.write(bytearray([hash32 >> 24 & 0xff])) - fp.write(bytearray([hash32 >> 16 & 0xff])) - fp.write(bytearray([hash32 >> 8 & 0xff])) - fp.write(bytearray([hash32 >> 0 & 0xff])) - fp.write(bytearray([font.height >> 8 & 0xff])) - fp.write(bytearray([font.height >> 0 & 0xff])) - fp.write(bytearray([font.yOffs >> 8 & 0xff])) - fp.write(bytearray([font.yOffs >> 0 & 0xff])) - fp.write(bytearray([numChars >> 24 & 0xff])) - fp.write(bytearray([numChars >> 16 & 0xff])) - fp.write(bytearray([numChars >> 8 & 0xff])) - fp.write(bytearray([numChars >> 0 & 0xff])) + fp.write(chr(hash32 >> 24 & 0xff)) + fp.write(chr(hash32 >> 16 & 0xff)) + fp.write(chr(hash32 >> 8 & 0xff)) + fp.write(chr(hash32 >> 0 & 0xff)) + fp.write(chr(font.height >> 8 & 0xff)) + fp.write(chr(font.height >> 0 & 0xff)) + fp.write(chr(font.yOffs >> 8 & 0xff)) + fp.write(chr(font.yOffs >> 0 & 0xff)) + fp.write(chr(numChars >> 24 & 0xff)) + fp.write(chr(numChars >> 16 & 0xff)) + fp.write(chr(numChars >> 8 & 0xff)) + fp.write(chr(numChars >> 0 & 0xff)) # Write a blank table at first (?) charTable = [0]*(numChars * CACHED_CHAR_SIZE) - fp.write(bytearray(charTable)) + for i in range(numChars * CACHED_CHAR_SIZE): + fp.write(chr(charTable[i])) # Loop over all characters tableIndex = 0 @@ -171,7 +173,8 @@ def renderFontSaveCached(font, filename, hash32): dBuffer.append(accum) # Write the data - fp.write(bytearray(dBuffer)) + for j in range(len(dBuffer)): + fp.write(chr(dBuffer[j])) destIndex = tableIndex * CACHED_CHAR_SIZE charTable[destIndex + 0] = i >> 8 & 0xff @@ -190,12 +193,13 @@ def renderFontSaveCached(font, filename, hash32): # Seek back to the beginning and rewrite the table fp.seek(CACHED_HEADER_SIZE, 0) - fp.write(bytearray(charTable)) + for i in range(numChars * CACHED_CHAR_SIZE): + fp.write(chr(charTable[i])) fp.close() return 0 - except: + #except: return 1 -- cgit v1.2.3