Fix some font directories from fonts.conf being ignored on linux when scanning the system for installed fonts. Fixes #1339257 [some font directories are ignored](https://bugs.launchpad.net/calibre/+bug/1339257)

This commit is contained in:
Kovid Goyal 2014-07-09 09:19:14 +05:30
parent 4b20fbbf10
commit da29398a26

View File

@ -78,15 +78,20 @@ def fc_list():
end(str_list) end(str_list)
if len(ans) < 3: if len(ans) < 3:
return default_font_dirs() return default_font_dirs()
parents = []
parents, visited = [], set()
for f in ans: for f in ans:
found = False path = os.path.normpath(os.path.abspath(os.path.realpath(f)))
for p in parents: if path == '/':
if f.startswith(p): continue
found = True head, tail = os.path.split(path)
while head and tail:
if head in visited:
break break
if not found: head, tail = os.path.split(head)
parents.append(f) else:
parents.append(path)
visited.add(path)
return parents return parents