Unverified Commit d44b4b86 authored by dmMaze's avatar dmMaze Committed by GitHub
Browse files

Merge pull request #242 from kagenihisomi/dev

Custom fonts
parents fef2b721 28e081cf
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -37,3 +37,6 @@ config/config.json
venv
pip
.DS_Store

fonts/*
!fonts/put fonts here.txt
 No newline at end of file
+0 −0

Empty file added.

+12 −0
Original line number Diff line number Diff line
from pathlib import Path
import sys
import argparse
import os.path as osp
@@ -20,6 +21,10 @@ REQ_WIN = [
    'pywin32'
]

PATH_ROOT=Path(__file__).parent  
PATH_FONTS=PATH_ROOT/'fonts'


parser = argparse.ArgumentParser()
parser.add_argument("--reinstall-torch", action='store_true', help="launch.py argument: install the appropriate version of torch even if you have some version already installed")
parser.add_argument("--proj-dir", default='', type=str, help='Open project directory on startup')
@@ -148,6 +153,7 @@ def main():
    from qtpy.QtCore import QTranslator, QLocale, Qt
    from qtpy.QtGui import QIcon
    from qtpy.QtGui import  QGuiApplication, QIcon, QFont
    from qtpy.QtGui import  QFontDatabase

    from ui import constants as C
    from ui import config as program_config
@@ -191,6 +197,12 @@ def main():
    C.LDPI = ps.logicalDotsPerInch()
    C.SCREEN_W = ps.geometry().width()
    C.SCREEN_H = ps.geometry().height()

    # Fonts
    # Load custom fonts if they exist
    for font in os.listdir(PATH_FONTS):
        if font.endswith(('.ttf','.otf')):
            QFontDatabase.addApplicationFont((PATH_FONTS/font).as_posix())
    yahei = QFont('Microsoft YaHei UI')
    if yahei.exactMatch():
        QGuiApplication.setFont(yahei)