extractor icon indicating copy to clipboard operation
extractor copied to clipboard

UnicodeDecodeError while converting name table entries with record.toUnicode()

Open typemytype opened this issue 4 years ago • 0 comments

reproducible with standaard Helvetica.ttc

proposal: fallback to the record.toUnicode("backslashreplace")

a PR is coming

from fontTools.ttLib import TTFont

path = '/System/Library/Fonts/Helvetica.ttc'
source = TTFont(path, fontNumber=1)

for record in source["name"].names:
    print(record.nameID, record.platformID, record.platEncID, record.langID, str(record))
    print(record.toUnicode("backslashreplace"))    # proposal fallback to a backslashreplace version
    print(record.toUnicode())    # <---- UnicodeDecodeError

typemytype avatar Dec 10 '21 13:12 typemytype