fxconv: replace _encode_{word,long} with u16, u32

This commit is contained in:
Lephenixnoir 2021-01-25 19:12:46 +01:00
parent 53ea134c62
commit 47504ff179
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 2 additions and 11 deletions

View File

@ -304,15 +304,6 @@ class Grid:
y = b + r * (H + b) + p
yield (x, y, x + w, y + h)
#
# Helpers
#
def _encode_word(x):
return bytes([ (x >> 8) & 255, x & 255 ])
def _encode_long(x):
return bytes([ (x >> 24) & 255, (x >> 16) & 255, (x >> 8) & 255, x & 255 ])
#
# Binary conversion
#
@ -585,7 +576,7 @@ def convert_topti(input, output, params, target):
def encode_block(b):
start, length = b
return _encode_long((start << 12) | length)
return u32((start << 12) | length)
data_blocks = b''.join(encode_block(b) for b in blocks)
@ -603,7 +594,7 @@ def convert_topti(input, output, params, target):
# Upate index
if not (number % 8):
idx = total_glyphs // 4
data_index += _encode_word(idx)
data_index += u16(idx)
# Get glyph area
glyph = img.crop(region)