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

Commit

Permalink
Merge pull request #162 from srevinsaju/fonttools
Browse files Browse the repository at this point in the history
Release 4.3.0
  • Loading branch information
srevinsaju authored Sep 2, 2020
2 parents cc1e4fd + 8a324c6 commit 574faa5
Show file tree
Hide file tree
Showing 27 changed files with 111,643 additions and 26,761 deletions.
12 changes: 6 additions & 6 deletions appimage/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export GUISCRCPY_SCRCPY=${APPDIR}/usr/bin/scrcpy
export GUISCRCPY_ADB=${APPDIR}/usr/bin/adb
export SCRCPY_SERVER_PATH=${APPDIR}/usr/local/share/scrcpy/scrcpy-server
export ADB=${APPDIR}/usr/bin/adb
export GUISCRCPY_SCRCPY="${APPDIR}/usr/bin/scrcpy"
export GUISCRCPY_ADB="${APPDIR}/usr/bin/adb"
export SCRCPY_SERVER_PATH="${APPDIR}/usr/local/share/scrcpy/scrcpy-server"
export ADB="${APPDIR}/usr/bin/adb"
export GUISCRCPY_APPIMAGE=True
export PATH=${APPDIR}/usr/bin:${PATH}
export PATH="${APPDIR}/usr/bin:${PATH}"

{{ python-executable }} -s ${APPDIR}/opt/python{{ python-version }}/bin/guiscrcpy "$@"
"{{ python-executable }}" -s "${APPDIR}/opt/python{{ python-version }}/bin/guiscrcpy" "$@"
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

[![Updates](https://pyup.io/repos/github/srevinsaju/guiscrcpy/shield.svg)](https://pyup.io/repos/github/srevinsaju/guiscrcpy/)[![Python 3](https://pyup.io/repos/github/srevinsaju/guiscrcpy/python-3-shield.svg)](https://pyup.io/repos/github/srevinsaju/guiscrcpy/)[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/guiscrcpy?style=flat-square)![PyPI](https://img.shields.io/pypi/v/guiscrcpy?style=flat-square)![PyPI - Wheel](https://img.shields.io/pypi/wheel/guiscrcpy?style=flat-square)![PyPI - Downloads](https://img.shields.io/pypi/dm/guiscrcpy?color=dark%20green&logo=PYPI&logoColor=Green&style=flat-square)](https://pypi.org/project/guiscrcpy)

[![Get guiscrcpy AppImage](https://img.shields.io/endpoint?url=https%3A%2F%2Fwww.srevinsaju.me%2Fget-appimage%2Fguiscrcpy%2Fshields.json)](https://www.srevinsaju.me/get-appimage/guiscrcpy/)

[![AUR version](https://img.shields.io/aur/version/guiscrcpy?label=Arch%20Linux%20Package&style=flat-square)](https://aur.archlinux.org/packages/guiscrcpy)
[![guiscrcpy](https://snapcraft.io//guiscrcpy/badge.svg)](https://snapcraft.io/guiscrcpy)
[![GitHub All Releases](https://img.shields.io/github/downloads/srevinsaju/guiscrcpy/total?style=flat-square)](https://github.com/srevinsaju/guiscrcpy/releases)
Expand Down
2 changes: 1 addition & 1 deletion guiscrcpy.desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Desktop Entry]
Version=4.2.0.dev
Version=4.3.0.dev
Name=guiscrcpy
GenericName=guiscrcpy
Comment=Open Source Android Screen Mirroring System
Expand Down
8 changes: 8 additions & 0 deletions guiscrcpy/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FONTS = [
'NotoSans-BoldItalic.ttf',
'NotoSans-Italic.ttf',
'TitilliumWeb-Bold.ttf',
'NotoSans-Bold.ttf',
'NotoSans-Regular.ttf',
'TitilliumWeb-Regular.ttf',
]
16 changes: 14 additions & 2 deletions guiscrcpy/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@

from qtpy import QtCore, QtWidgets
from qtpy.QtCore import QModelIndex, QPoint
from qtpy.QtGui import QPixmap, QIcon, QFont
from qtpy.QtGui import QPixmap, QIcon, QFont, QFontDatabase
from qtpy.QtWidgets import QMainWindow, QApplication, QListWidgetItem, QMenu
from qtpy.QtWidgets import QMessageBox

from .lib.utils import format_colors as fc
from .constants import FONTS
from .install.finder import open_exe_name_dialog
from .lib.process import is_running
from .lib.toolkit import UXMapper
Expand Down Expand Up @@ -1204,6 +1205,17 @@ def bootstrap(cfgmgr, theme='Breeze', aot=True, debug__no_scrcpy=False,
QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
# init core
app = QtWidgets.QApplication([])

# load fonts
font_database = QFontDatabase()
for font in FONTS:
s = font_database.addApplicationFont(':/font/fonts/{ttf}'.format(
ttf=font
))
if s == -1: # loading the font failed
# https://doc.qt.io/qt-5/qfontdatabase.html
print(fc("{y}Failed to load {ttf} font.{rst}", ttf=font))

# set theme
app.setStyle(theme)
# apply stylesheet
Expand Down
4 changes: 4 additions & 0 deletions guiscrcpy/platform/darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ def increment(self):
@staticmethod
def paths():
return ['bin', '/usr/bin', '~/.local/bin', '~/bin', '/usr/local/bin']

@staticmethod
def install_fonts():
return True
43 changes: 2 additions & 41 deletions guiscrcpy/platform/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,47 +103,8 @@ def create_desktop(desktop_file=None,

@staticmethod
def install_fonts():
"""
Install fonts to ~/.fonts.
The fonts being installed is Titillium Web ~
https://fonts.google.com/specimen/Titillium+Web
Open Source Approved fonts.
# TODO support for SystemWide Installation
:return: True if installation successful, else False
"""
sys_font_dir = os.path.join(os.path.expanduser('~'), '.fonts')
if not os.path.exists(sys_font_dir):
os.makedirs(sys_font_dir)

try:
from fontTools.ttLib import TTFont
except ModuleNotFoundError 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 "
"Error: {}".format(e)
)
return False

font_dir = os.path.join(os.path.abspath(
os.path.dirname(os.path.dirname(__file__))), 'ui', 'fonts')
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 "
"Error: {}".format(e)
)
return False
# deprecate install fonts for Linux
return True

@staticmethod
def system():
Expand Down
41 changes: 1 addition & 40 deletions guiscrcpy/platform/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,46 +57,7 @@ def paths():

@staticmethod
def install_fonts():
"""
Install fonts to system directory.
The fonts being installed is Titillium Web ~
https://fonts.google.com/specimen/Titillium+Web
Open Source Approved fonts.
# TODO support for SystemWide Installation
:return: True if installation successful, else False
"""
# TODO: Test it properly
# Likely to fail
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'
)
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"
"Error: {}".format(e)
)
return False
return True

@staticmethod
def create_desktop():
Expand Down
1 change: 1 addition & 0 deletions guiscrcpy/ui/bottompanelui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ color: rgb(0, 0, 0);
</property>
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
Expand Down
Binary file added guiscrcpy/ui/fonts/NotoSans-Bold.ttf
Binary file not shown.
Binary file added guiscrcpy/ui/fonts/NotoSans-BoldItalic.ttf
Binary file not shown.
Binary file added guiscrcpy/ui/fonts/NotoSans-Italic.ttf
Binary file not shown.
28 changes: 23 additions & 5 deletions guiscrcpy/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ border-radius: 10px;
<widget class="QCheckBox" name="check_swipe_panel">
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>10</pointsize>
</font>
</property>
Expand Down Expand Up @@ -400,6 +401,7 @@ border-radius: 10px;
<widget class="QCheckBox" name="lock_rotation">
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>10</pointsize>
</font>
</property>
Expand All @@ -416,6 +418,7 @@ border-radius: 10px;
<widget class="QCheckBox" name="check_bottom_panel">
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>10</pointsize>
</font>
</property>
Expand Down Expand Up @@ -455,6 +458,7 @@ border-radius: 10px;
<widget class="QCheckBox" name="check_side_panel">
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>10</pointsize>
</font>
</property>
Expand Down Expand Up @@ -486,6 +490,12 @@ border-radius: 10px;
</item>
<item row="7" column="5">
<widget class="QComboBox" name="device_rotation">
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>11</pointsize>
</font>
</property>
<item>
<property name="text">
<string>Default Rotation</string>
Expand Down Expand Up @@ -572,6 +582,7 @@ border-radius: 10px;
</property>
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>9</pointsize>
</font>
</property>
Expand Down Expand Up @@ -645,9 +656,16 @@ border-radius: 10px;
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>

</widget>
</item>
<item>
Expand All @@ -665,7 +683,7 @@ border-radius: 10px;
</property>
<property name="font">
<font>
<family>Titillium Web</family>
<family>Noto Sans</family>
<pointsize>11</pointsize>
<weight>50</weight>
<italic>false</italic>
Expand All @@ -690,7 +708,7 @@ border-radius: 10px;
</property>
<property name="font">
<font>
<family>Titillium Web</family>
<family>Noto Sans</family>
<pointsize>11</pointsize>
</font>
</property>
Expand Down Expand Up @@ -742,7 +760,7 @@ background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb
</property>
<property name="font">
<font>
<family>Trebuchet MS</family>
<family>Noto Sans</family>
<pointsize>11</pointsize>
</font>
</property>
Expand Down Expand Up @@ -881,7 +899,7 @@ border-radius: 10px;
</property>
<property name="font">
<font>
<family>Courier 10 Pitch</family>
<family>Monospace</family>
</font>
</property>
<property name="placeholderText">
Expand Down Expand Up @@ -1582,7 +1600,7 @@ border-radius: 10px;
</property>
<property name="font">
<font>
<family>Titillium Web</family>
<family>Noto Sans</family>
</font>
</property>
<property name="styleSheet">
Expand Down
2 changes: 1 addition & 1 deletion guiscrcpy/ui/network.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<string>Network Manager</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>2</x>
Expand Down
Loading

0 comments on commit 574faa5

Please sign in to comment.