FontFinder does not recurse into sub-directories

Issue #126 resolved
htgoebel
created an issue

On current GNU/Linux systems, the personal fonts are stored in sub-directories of the ~/.fonts directory.

Example: Font Hack installed

$ tree ~/.fonts
~/.fonts
└── h
    ├── Hack_BoldItalic.ttf
    ├── Hack_Bold.ttf
    ├── Hack_Italic.ttf
    └── Hack_Regular.ttf

This code shows the issue:

from reportlab.lib import fontfinder
ff = fontfinder.FontFinder()
ff.addDirectory(os.path.expanduser('~/.fonts'))
ff.search()
print(len(ff.getFamilyNames()))
ff.addDirectory(os.path.expanduser('~/.fonts/h'))
ff.search()
print(len(ff.getFamilyNames()))

Output:

0
1

Comments (2)

  1. Robin Becker

    I have added a recur=False argument to the FontFinder.init, it seems to do what you want when set to True. I don't think we use the FontFinder at all in our usage of the RL toolkit so this module has been overlooked.

  2. htgoebel reporter

    Thanks for your quick response. Unfortunately this uncovers another small bug: line 279 is using only the basename of the file. It should be

    … = TTFontFile(f.fileName …
    

    (mind the f. in front of fileName)

  3. Log in to comment