Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Stopped errors when css block has no font property (fixes #41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirpal committed Jul 10, 2018
1 parent ed6e223 commit 2c6c1c5
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions import_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,26 +426,26 @@ def read(filepath):

selectors = filter(None, pair[0].split(","))

font = list(filter(lambda p: re.sub(
r"\s+", "", p.split(":")[0]) == "font-family", props))[-1]
font = re.sub(r"(\'|\")", "", font.split(":")[1]).strip()
fontProperty = list(filter(lambda p: re.sub(r"\s+", "", p.split(":")[0]) == "font-family", props))
if len(fontProperty) > 0:
font = re.sub(r"(\'|\")", "", fontProperty[-1].split(":")[1]).strip()

if font in googleFonts.keys():
tempDir = bpy.app.tempdir
urllib.request.urlretrieve(
googleFonts[font], os.path.join(tempDir, font + ".ttf"))
font = bpy.data.fonts.load(
os.path.join(tempDir, font + ".ttf"))
if font in googleFonts.keys():
tempDir = bpy.app.tempdir
urllib.request.urlretrieve(
googleFonts[font], os.path.join(tempDir, font + ".ttf"))
font = bpy.data.fonts.load(
os.path.join(tempDir, font + ".ttf"))

else:
font = gotham

for selector in selectors:
if selector == "*":
fonts = [font for i in range(0, 12)]
elif re.fullmatch(r".keylabel[0-9][1-2]?") and int(selector.replace(".keylabel", "")) >= 0 and int(selector.replace(".keylabel", "")) <= 11:
fonts[int(selector.replace(
".keylabel", ""))] = font
else:
font = gotham

for selector in selectors:
if selector == "*":
fonts = [font for i in range(0, 12)]
elif re.fullmatch(r".keylabel[0-9][1-2]?") and int(selector.replace(".keylabel", "")) >= 0 and int(selector.replace(".keylabel", "")) <= 11:
fonts[int(selector.replace(
".keylabel", ""))] = font

bpy.context.window_manager.progress_begin(keyboard["keyCount"], 0)
bpy.context.window.cursor_set("DEFAULT")
Expand Down

0 comments on commit 2c6c1c5

Please sign in to comment.