[OpenFontFormat] Rename read_utils.py -> io_utils.py

This commit is contained in:
germax26 2024-05-04 11:49:09 +10:00
parent 1571f5c9d5
commit aca0461c26
Signed by: germax26
SSH Key Fingerprint: SHA256:N3w+8798IMWBt7SYH8G1C0iJlIa2HIIcRCXwILT5FvM
2 changed files with 7 additions and 2 deletions

View File

@ -7,7 +7,7 @@ from types import TracebackType
from typing import Callable, Generic, List, Optional, Tuple, Type, TypeVar, BinaryIO, Self from typing import Callable, Generic, List, Optional, Tuple, Type, TypeVar, BinaryIO, Self
from abcde import ABD, ABE from abcde import ABD, ABE
from read_utils import read_ascii, read_fixed_point, read_i16, read_i32, read_i8, read_int, read_pascal_string, read_u16, read_u24, read_u32, read_u64, read_u8 from io_utils import read_ascii, read_fixed_point, read_i16, read_i32, read_i8, read_int, read_pascal_string, read_u16, read_u24, read_u32, read_u64, read_u8
def read_fixed(f: BinaryIO) -> float: # 16.16 def read_fixed(f: BinaryIO) -> float: # 16.16
return read_fixed_point(f, 16, 16) return read_fixed_point(f, 16, 16)

View File

@ -1,6 +1,9 @@
from typing import BinaryIO from typing import BinaryIO
def read_int(f: BinaryIO, number: int, signed:bool=False) -> int: return int.from_bytes(f.read(number), 'big', signed=signed) ENDIANNESS = 'big'
def read_int(f: BinaryIO, number: int, signed:bool=False) -> int: return int.from_bytes(f.read(number), ENDIANNESS, signed=signed)
def write_int(f: BinaryIO, value: int, number: int, signed:bool=False) -> int: return f.write(value.to_bytes(number, ENDIANNESS, signed=signed))
def read_u64(f: BinaryIO) -> int: return read_int(f, 8) def read_u64(f: BinaryIO) -> int: return read_int(f, 8)
def read_u32(f: BinaryIO) -> int: return read_int(f, 4) def read_u32(f: BinaryIO) -> int: return read_int(f, 4)
@ -8,6 +11,8 @@ def read_u24(f: BinaryIO) -> int: return read_int(f, 3)
def read_u16(f: BinaryIO) -> int: return read_int(f, 2) def read_u16(f: BinaryIO) -> int: return read_int(f, 2)
def read_u8(f: BinaryIO) -> int: return read_int(f, 1) def read_u8(f: BinaryIO) -> int: return read_int(f, 1)
def write_u16(f: BinaryIO, value: int) -> int: return f.write(value)
def read_i32(f: BinaryIO) -> int: return read_int(f, 4, signed=True) def read_i32(f: BinaryIO) -> int: return read_int(f, 4, signed=True)
def read_i16(f: BinaryIO) -> int: return read_int(f, 2, signed=True) def read_i16(f: BinaryIO) -> int: return read_int(f, 2, signed=True)
def read_i8(f: BinaryIO) -> int: return read_int(f, 1, signed=True) def read_i8(f: BinaryIO) -> int: return read_int(f, 1, signed=True)