Skip to content

Wrong reader in mathext.py #7106

Closed
Closed
@lijunsun

Description

@lijunsun

This bug happens when drawing a figure when using AFM fonts (ps.useafm=True) and setting ScalarFormatter(useMathText=True),

The _sanity_check() function in aft.py requires a BufferedReader, while the "_get_font()" function in mathext.py returns TextIOWrapper

if cached_font is None:
fname = os.path.join(self.basepath, basename + ".afm")
with open(fname, 'r') as fd:
print(fd)
cached_font = AFM(fd)
cached_font.fname = fname
self.fonts[basename] = cached_font
self.fonts[cached_font.get_fontname()] = cached_font
return cached_font

The line "with open(fname, 'r') as fd:" should be "with open(fname, 'rb') as fd:"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions