From 47504ff1791d7db41ec5deac213baa0e90fce828 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Mon, 25 Jan 2021 19:12:46 +0100 Subject: [PATCH] fxconv: replace _encode_{word,long} with u16, u32 --- fxconv/fxconv.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fxconv/fxconv.py b/fxconv/fxconv.py index 9c60861..2937a94 100644 --- a/fxconv/fxconv.py +++ b/fxconv/fxconv.py @@ -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)