mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
OS X: Do not hang the UI waiting for fontconfig to finish scanning on first start. Instead present a blank list of available fonts
This commit is contained in:
parent
80fc2c7c68
commit
737458dc31
@ -118,7 +118,7 @@ class FontFamilyChooser(QComboBox):
|
||||
QComboBox.__init__(self, parent)
|
||||
from calibre.utils.fonts import fontconfig
|
||||
try:
|
||||
self.families = fontconfig.find_font_families()
|
||||
ok, self.families = fontconfig.find_font_families_no_delay()
|
||||
except:
|
||||
self.families = []
|
||||
print ('WARNING: Could not load fonts')
|
||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from calibre.constants import iswindows
|
||||
from calibre.constants import iswindows, isosx
|
||||
|
||||
class Fonts(object):
|
||||
|
||||
@ -23,6 +23,12 @@ class Fonts(object):
|
||||
return self.backend.font_families()
|
||||
return self.backend.find_font_families(allowed_extensions=allowed_extensions)
|
||||
|
||||
def find_font_families_no_delay(self, allowed_extensions={'ttf', 'otf'}):
|
||||
if isosx:
|
||||
if self.backend.is_scanning():
|
||||
return False, []
|
||||
return True, self.find_font_families(allowed_extensions=allowed_extensions)
|
||||
|
||||
def files_for_family(self, family, normalize=True):
|
||||
'''
|
||||
Find all the variants in the font family `family`.
|
||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, sys
|
||||
|
||||
from calibre.constants import plugins, islinux, isbsd
|
||||
from calibre.constants import plugins, islinux, isbsd, isosx
|
||||
|
||||
_fc, _fc_err = plugins['fontconfig']
|
||||
|
||||
@ -44,6 +44,11 @@ class FontConfig(Thread):
|
||||
if not self.failed and hasattr(_fc, 'add_font_dir'):
|
||||
_fc.add_font_dir(P('fonts/liberation'))
|
||||
|
||||
def is_scanning(self):
|
||||
if isosx:
|
||||
return self.is_alive()
|
||||
return False
|
||||
|
||||
def wait(self):
|
||||
if not (islinux or isbsd):
|
||||
self.join()
|
||||
|
Loading…
x
Reference in New Issue
Block a user