Ejemplo n.º 1
0
tr = TableRecord.createNewTableRecord("bcde", 42)
testResults["TableRecord.createNewTableRecord test 5"] = (
    tr.tableTag == "bcde")
testResults["TableRecord.createNewTableRecord test 6"] = (tr.checkSum == 42)
testResults["TableRecord.createNewTableRecord test 7"] = (tr.offset == 0)
tr = TableRecord.createNewTableRecord("cdef", 42, 43, 44)
testResults["TableRecord.createNewTableRecord test 8"] = (
    tr.tableTag == "cdef")
testResults["TableRecord.createNewTableRecord test 9"] = (tr.checkSum == 42)
testResults["TableRecord.createNewTableRecord test 10"] = (tr.offset == 43)
testResults["TableRecord.createNewTableRecord test 11"] = (tr.length == 44)

#-------------------------------------------------------------
# tests for TableRecord.tryReadFromBuffer

selawk_file = getTestFontOTFile("Selawik")
sourceHansSans_file = getTestFontOTFile("SourceHansSans")

offtbl = selawk_file.fonts[0].offsetTable
tblrec = list(offtbl.tableRecords.values())[0]
testResults["TableRecord test 1"] = (tblrec.tableTag == "DSIG")
testResults["TableRecord test 2"] = (tblrec.checkSum == 0xF054_3E26)
testResults["TableRecord test 3"] = (tblrec.offset == 0x0000_91E4)
testResults["TableRecord test 4"] = (tblrec.length == 0x0000_1ADC)

tblrec = list(offtbl.tableRecords.values())[5]
testResults["TableRecord test 5"] = (tblrec.tableTag == "cmap")
testResults["TableRecord test 6"] = (tblrec.checkSum == 0x22F2_F74C)
testResults["TableRecord test 7"] = (tblrec.offset == 0x0000_0758)
testResults["TableRecord test 8"] = (tblrec.length == 0x0000_0606)
Ejemplo n.º 2
0
testResults["Table_COLR.createNew_COLR test 2"] = result

# createNew_COLR: check default values for version 1
colr = Table_COLR.createNew_COLR(1)
testResults["Table_COLR.createNew_COLR test 3"] = (type(colr) == Table_COLR)
result = True
expected = zip(Table_COLR._colr_1_all_fields, Table_COLR._colr_1_all_defaults)
for k, v in expected:
    val = getattr(colr, k)
    if val != v:
        result = False
        break
testResults["Table_COLR.createNew_COLR test 4"] = result

# test Table_COLR.tryReadFromFile using BungeeColor-Regular_colr_Windows.ttf
bungeeColor_file = getTestFontOTFile("BungeeColor")

try:
    colr = bungeeColor_file.fonts[0].tables["COLR"]
except Exception:
    result = False
else:
    result = True
testResults["Table_COLR.tryReadFromFile test 1"] = result
testResults["Table_COLR.tryReadFromFile test 2"] = (type(colr) == Table_COLR)
bungeeColor_COLR_headerValues = (0, 288, 14, 1742, 576)
result = True
expected = zip(Table_COLR._colr_0_fields, bungeeColor_COLR_headerValues)
for k, v in expected:
    val = getattr(colr, k)
    if val != v:
Ejemplo n.º 3
0
    val = getattr(maxp, k)
    if val != v:
        result = False
        break
testResults["Table_maxp.createNew_maxp test 5"] = result
result = True
expected = zip(Table_maxp._maxp_1_0_addl_fields, Table_maxp._maxp_1_0_addl_defaults)
for k, v in expected:
    val = getattr(maxp, k)
    if val != v:
        result = False
        break
testResults["Table_maxp.createNew_maxp test 6"] = result

# test Table_maxp.tryReadFromFile using selawk.ttf
selawk_file = getTestFontOTFile("Selawik")
try:
    maxp = selawk_file.fonts[0].tables["maxp"]
except Exception:
    result = False
else:
    result = True
testResults["Table_maxp.tryReadFromFile test 1"] = result
testResults["Table_maxp.tryReadFromFile test 2"] = (type(maxp) == Table_maxp)
selawk_maxp_values = [1, 0x0160, 0x64, 7, 0x4d, 4, 0, 0, 0, 1, 0, 0, 0, 3, 1]
result = True
expected = zip(Table_maxp._maxp_1_0_all_fields, selawk_maxp_values)
for k, v in expected:
    val = getattr(maxp, k)
    if val != v:
        result = False