Skip to content

Commit

Permalink
ENH: Load application fronts from directory
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtJacobson committed Sep 25, 2020
1 parent 41a183c commit 18f9f3d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions qtpyvcp/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def __init__(self, theme=None, stylesheet=None, custom_fonts=[]):
self.loadStylesheet(stylesheet, opts.develop)

if custom_fonts:
if isinstance(custom_fonts, basestring): # single font
self.loadFont(custom_fonts)
else: # list of fonts
if isinstance(custom_fonts, basestring): # single font or location
self.loadCustomFont(custom_fonts)
else: # list of fonts or locations
for font in custom_fonts:
self.loadFont(font)
self.loadCustomFont(font)

# self.window = self.loadVCPMainWindow(opts, vcp_file)
# if self.window is not None:
Expand Down Expand Up @@ -194,7 +194,16 @@ def load(path):

load(stylesheet)

def loadFont(self, font_path):
def loadCustomFont(self, font):
"""Loads custom front from a file or directory."""
if os.path.isfile(font):
self.addApplicationFont(font)
elif os.path.isdir(font):
for ffile in os.listdir(font):
fpath = os.path.join(font, ffile)
self.loadCustomFont(fpath)

def addApplicationFont(self, font_path):
"""Loads a font file into the font database. The path can specify the
location of a font file or a qresource."""
LOG.debug("Loading custom font: %s" % font_path)
Expand Down

0 comments on commit 18f9f3d

Please # to comment.