Skip to content

Type of Font.m_FontData being mixed up #344

@t-wy

Description

@t-wy

Code
From README.md:

if obj.type.name == "Font":
    font: Font = obj.read()
    if font.m_FontData:
        extension = ".ttf"
        if font.m_FontData[0:4] == b"OTTO":
            extension = ".otf"

    with open(os.path.join(path, font.m_Name+extension), "wb") as f:
        f.write(font.m_FontData)

Error
The error message that is produced by python.

Usually something like
TypeError: memoryview: a bytes-like object is required, not 'list'

Bug
From the example in README.md, it seems that Font.m_FontData is treated as a bytes object.
While in generated classes (classes.generated), Font.m_FontData is typed with List[str].
However in real usage, Font.m_FontData actually returns List[int] containing the byte values as a list.

To Reproduce

  • a copy of the file that causes the problem
  • following data:
    • Python version: 3.10.12
    • UnityPy version: 1.22.3, 1.22.5 and 1.23.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions