import base64 import io import os from fontTools.misc.testTools import getXML from fontTools.ttLib import TTFont DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data") # This is a subset from NotoColorEmoji.ttf which contains an IndexTable format=3 INDEX_FORMAT_3_TTX = os.path.join(DATA_DIR, "NotoColorEmoji.subset.index_format_3.ttx") # The CLBC table was compiled with Harfbuzz' hb-subset and contains the correct padding CBLC_INDEX_FORMAT_3 = base64.b64decode( "AAMAAAAAAAEAAAA4AAAALAAAAAIAAAAAZeWIAAAAAAAAAAAAZeWIAAAAAAAAAAAAAAEAA" "21tIAEAAQACAAAAEAADAAMAAAAgAAMAEQAAAAQAAAOmEQ0AAAADABEAABERAAAIUg==" ) def test_compile_decompile_index_table_format_3(): font = TTFont() font.importXML(INDEX_FORMAT_3_TTX) buf = io.BytesIO() font.save(buf) buf.seek(0) font = TTFont(buf) assert font.reader["CBLC"] == CBLC_INDEX_FORMAT_3 assert getXML(font["CBLC"].toXML, font) == [ '
', '', " ", ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', " ", ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', " ", ' ', ' ', ' ', ' ', ' ', ' ', ' ', " ", " ", ' ', ' ', ' ', " ", ' ', ' ', " ", "", ]