Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
Fix #75. Fix FileNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
srevinsaju committed Mar 26, 2020
1 parent 5eae11f commit cbd36e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion guiscrcpy/platform/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ def install_fonts():
os.makedirs(sys_font_dir)
from fontTools.ttLib import TTFont
font_dir = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), 'ui', 'fonts')
fonts = os.listdir(font_dir)
try:
fonts = os.listdir(font_dir)
for i in fonts:
font = TTFont(os.path.join(font_dir, i))
font.save(os.path.join(sys_font_dir, i))
return True
except Exception as e:
logging.error("Error Installing the fonts. "
"You might have to manually install the fonts"
"Titillium Web : https://fonts.google.com/specimen/Titillium+Web")
return False

@staticmethod
Expand Down
9 changes: 6 additions & 3 deletions guiscrcpy/platform/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,22 @@ def install_fonts(self):
"""
# TODO: Test it properly
# Likely to fail
cmd = r"""copy "{fontdir}" "%WINDIR%\Fonts"
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /
cmd = r"""copy "{fontdir}" "%WINDIR%\Fonts"
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /
v "FontName (TrueType)" / t REG_SZ / d {font} / f """
font_dir = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), 'ui', 'fonts')
fonts = os.listdir(font_dir)
try:
fonts = os.listdir(font_dir)
for i in fonts:
# install the fonts by executing cmd and update the Windows Registry
print(cmd.format(font=i, fontdir=os.path.join(font_dir, i)))
os.system(cmd.format(font=i, fontdir=os.path.join(font_dir, i)))
return True
except Exception as e:
print("Installing fonts failed")
logging.error("Error Installing the fonts. "
"You might have to manually install the fonts"
"Titillium Web : https://fonts.google.com/specimen/Titillium+Web")
return False

def create_desktop(self):
Expand Down

0 comments on commit cbd36e3

Please sign in to comment.