Skip to content

KeyError from ttfFontProperty while parsing  #363

@kitchoi

Description

@kitchoi

While importing font_manager on Appveyor, we found a number of similar traceback, pointing towards a failure to parse default system fonts.

The errors look like this:

[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\msjhl.ttc
[00:03:39] Traceback (most recent call last):
[00:03:39]   File "C:\Users\appveyor\.edm\envs\py36-ci\lib\site-packages\kiva\fonttools\font_manager.py", line 1440, in <module>
[00:03:39]     fontManager = pickle_load(_fmcache)
[00:03:39]   File "C:\Users\appveyor\.edm\envs\py36-ci\lib\site-packages\kiva\fonttools\font_manager.py", line 1050, in pickle_load
[00:03:39]     fh = open(filename, 'rb')
[00:03:39] FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\appveyor\\AppData\\Roaming\\Enthought\\kiva\\fontList.cache'
[00:03:39]
[00:03:39] During handling of the above exception, another exception occurred:
[00:03:39]
[00:03:39] Traceback (most recent call last):
[00:03:39]   File "C:\Users\appveyor\.edm\envs\py36-ci\lib\site-packages\kiva\fonttools\font_manager.py", line 717, in createFontList
[00:03:39]     props.append(ttfFontProperty(fpath, font))
[00:03:39]   File "C:\Users\appveyor\.edm\envs\py36-ci\lib\site-packages\kiva\fonttools\font_manager.py", line 525, in ttfFontProperty
[00:03:39]     name = props[(1, 0, 0, 1)].decode()
[00:03:39] KeyError: (1, 0, 0, 1)

There are 50 font files that trigger this error.

From the test log:
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\msjhl.ttc
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguisym.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\leelauib.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\segoeuii.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\segoeuisl.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\msyh.ttc
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguisli.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguibl.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\segoeuiz.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguisbi.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\yugothic.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\segoeuib.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\ebrima.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguibli.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguili.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguiemj.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\simhei.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\segoeui.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\tahomabd.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\seguisb.ttf
[00:03:39] Could not covert font to FontEntry for file c:\windows\fonts\tahoma.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\msyhl.ttc
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\leelawui.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\msgothic.ttc
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\yugothib.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\yumindb.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\leeluisl.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\msjhbd.ttc
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\msyhbd.ttc
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\yuminl.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\segoeuil.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\ebrimabd.ttf
[00:03:40] Could not covert font to FontEntry for file c:\windows\fonts\msjh.ttc
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\yugothil.ttf
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\yumin.ttf
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\segoewp-black.ttf
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\segoewp-bold.ttf
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\segoewp-semibold.ttf
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\segoewp-light.ttf
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\segoewp-semilight.ttf
[00:03:41] Could not covert font to FontEntry for file c:\windows\fonts\segoewp.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\LeelaUIb.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\LeelawUI.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\LeelUIsl.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\SegoeWP-Black.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\SegoeWP-Bold.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\SegoeWP-Light.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\SegoeWP-Semibold.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\SegoeWP-Semilight.ttf
[00:03:41] Could not covert font to FontEntry for file C:\windows\Fonts\SegoeWP.ttf

In other words, this line fails with KeyError, could we have handled this differently?:

name = props[(1, 0, 0, 1)].decode()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions