def makeBitwiseIdenticalNonStandardTable1():
    header, directory, tableData = defaultSFNTTestData()
    # adjust the header
    header["numTables"] += 1
    # store the data
    data = "\0" * 4
    tableData["TEST"] = data
    # offset the directory entries
    for entry in directory:
        entry["offset"] += sfntDirectoryEntrySize
    # find the offset
    entries = [(entry["offset"], entry) for entry in directory]
    entry = max(entries)[1]
    offset = entry["offset"] + entry["length"]
    offset += calcPaddingLength(offset)
    # make the entry
    directory.append(
        dict(
            tag="TEST",
            offset=offset,
            length=4,
            checksum=calcTableChecksum("TEST", data)
        )
    )
    # compile
    data = packSFNT(header, directory, tableData)
    return data
def makeInvalidPadding2():
    header, directory, tableData = defaultSFNTTestData()
    # pad the tables and update their offsets
    entries = [(entry["offset"], entry) for entry in directory]
    for o, entry in sorted(entries):
        tag = entry["tag"]
        data = tableData[tag]
        tableData[tag] = padData(data)
        entry["offset"] += sfntDirectoryEntrySize
    # make a bogus table and insert it
    header["numTables"] += 1
    data = "\01" * 15
    tableData["zzzz"] = data
    offset = entry["offset"] + entry["length"] + calcPaddingLength(entry["length"])
    directory.append(
        dict(
            tag="zzzz",
            offset=offset,
            length=15,
            checksum=calcTableChecksum("zzzz", data)
        )
    )
    # compile
    data = packSFNT(header, directory, tableData, applyPadding=False)
    return data
def makeTableDirectoryAscending1():
    header, directory, tableData = defaultSFNTTestData()
    # adjust the header
    header["numTables"] += len(dummyTables)
    # adjust the offsets
    shift = len(dummyTables) * sfntDirectoryEntrySize
    for entry in directory:
        entry["offset"] += shift
    # store the data
    sorter = [(entry["offset"], entry["length"]) for entry in directory]
    offset, length = max(sorter)
    offset = offset + length
    data = "\0" * 4
    checksum = calcTableChecksum(None, data)
    for tag in dummyTables:
        tableData[tag] = data
        entry = dict(
            tag=tag,
            offset=offset,
            length=4,
            checksum=checksum
        )
        directory.append(entry)
        offset += 4
    # compile
    data = packSFNT(header, directory, tableData)
    return data
def makeUnknownTables():
    from testCaseGeneratorLib.woff import knownTableTags

    header, directory, tableData = defaultSFNTTestData(flavor="TTF")
    # adjust the header
    header["numTables"] += len(dummyTables)
    # adjust the offsets
    shift = len(dummyTables) * sfntDirectoryEntrySize
    for entry in directory:
        entry["offset"] += shift
    # store the data
    sorter = [(entry["offset"], entry["length"]) for entry in directory]
    offset, length = max(sorter)
    offset = offset + length
    data = "\0" * 4
    checksum = calcTableChecksum(None, data)
    for tag in dummyTables:
        tableData[tag] = data
        entry = dict(
            tag=tag,
            offset=offset,
            length=4,
            checksum=checksum
        )
        directory.append(entry)
        offset += 4

    tags = [e["tag"] for e in directory]
    assert not set(tags) < set(knownTableTags)

    data = packSFNT(header, directory, tableData, flavor="TTF")
    return data
def makeDSIG(flavor="CFF"):
    header, directory, tableData = defaultSFNTTestData(flavor=flavor)
    # adjust the header
    header["numTables"] += 1
    # store the data
    data = "\0" * 4
    tableData["DSIG"] = data
    # offset the directory entries
    for entry in directory:
        entry["offset"] += sfntDirectoryEntrySize
    # find the offset
    entries = [(entry["offset"], entry) for entry in directory]
    entry = max(entries)[1]
    offset = entry["offset"] + entry["length"]
    offset += calcPaddingLength(offset)
    # make the entry
    directory.append(
        dict(
            tag="DSIG",
            offset=offset,
            length=4,
            checksum=calcTableChecksum("DSIG", data)
        )
    )
    # compile
    data = packSFNT(header, directory, tableData, flavor=flavor)
    return data
Beispiel #6
0
def makeTableDirectoryAscending1():
    header, directory, tableData = defaultSFNTTestData()
    # adjust the header
    header["numTables"] += len(dummyTables)
    # adjust the offsets
    shift = len(dummyTables) * sfntDirectoryEntrySize
    for entry in directory:
        entry["offset"] += shift
    # store the data
    sorter = [(entry["offset"], entry["length"]) for entry in directory]
    offset, length = max(sorter)
    offset = offset + length
    data = "\0" * 4
    checksum = calcTableChecksum(None, data)
    for tag in dummyTables:
        tableData[tag] = data
        entry = dict(tag=tag, offset=offset, length=4, checksum=checksum)
        directory.append(entry)
        offset += 4
    # compile
    data = packSFNT(header, directory, tableData)
    return data
Beispiel #7
0
def makeInvalidPadding2():
    header, directory, tableData = defaultSFNTTestData()
    # pad the tables and update their offsets
    entries = [(entry["offset"], entry) for entry in directory]
    for o, entry in sorted(entries):
        tag = entry["tag"]
        data = tableData[tag]
        tableData[tag] = padData(data)
        entry["offset"] += sfntDirectoryEntrySize
    # make a bogus table and insert it
    header["numTables"] += 1
    data = "\01" * 15
    tableData["zzzz"] = data
    offset = entry["offset"] + entry["length"] + calcPaddingLength(
        entry["length"])
    directory.append(
        dict(tag="zzzz",
             offset=offset,
             length=15,
             checksum=calcTableChecksum("zzzz", data)))
    # compile
    data = packSFNT(header, directory, tableData, applyPadding=False)
    return data
Beispiel #8
0
def makeBitwiseIdenticalNonStandardTable1():
    header, directory, tableData = defaultSFNTTestData()
    # adjust the header
    header["numTables"] += 1
    # store the data
    data = "\0" * 4
    tableData["TEST"] = data
    # offset the directory entries
    for entry in directory:
        entry["offset"] += sfntDirectoryEntrySize
    # find the offset
    entries = [(entry["offset"], entry) for entry in directory]
    entry = max(entries)[1]
    offset = entry["offset"] + entry["length"]
    offset += calcPaddingLength(offset)
    # make the entry
    directory.append(
        dict(tag="TEST",
             offset=offset,
             length=4,
             checksum=calcTableChecksum("TEST", data)))
    # compile
    data = packSFNT(header, directory, tableData)
    return data