mirror of
https://github.com/holub/mame
synced 2025-04-25 01:40:16 +03:00
png2bdc.py: Converted to python 2.5 syntax. (nw)
This commit is contained in:
parent
04e88850a9
commit
974bf6697e
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user