mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-22 00:03:18 +02: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
3 changed files with 14 additions and 3 deletions
|
|
@ -118,7 +118,7 @@ def __init__(self, parent=None):
|
|||
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 @@
|
|||
__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 @@ def find_font_families(self, allowed_extensions={'ttf', 'otf'}):
|
|||
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 @@
|
|||
|
||||
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 @@ def run(self):
|
|||
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…
Reference in a new issue