Beispiel #1
0
def install_fonts():
    database = QtGui.QFontDatabase()

    for font in (os.path.join("opensans", "OpenSans-Regular.ttf"),
                 os.path.join("opensans", "OpenSans-Semibold.ttf"),
                 os.path.join("fontawesome", "fontawesome-webfont.ttf")):
        path = util.get_asset("font", font)

        # TODO(marcus): Check if they are already installed first.
        # In hosts, this will be called each time the GUI is shown,
        # potentially installing a font each time.
        if database.addApplicationFont(path) < 0:
            sys.stderr.write("Could not install %s\n" % path)
        else:
            sys.stdout.write("Installed %s\n" % font)
Beispiel #2
0
def add_fonts(font_directory):
    """Add extra fonts to QApplication.

    Args:
        font_directory (string): Path where fonts live

    Returns:
        bool: True if successful, False if not.
    """
    valid_types = ['ttf', 'otf']
    fonts = QtGui.QFontDatabase()
    for thing in os.listdir(font_directory):
        thing_path = os.path.join(font_directory, thing)
        if os.path.isfile(thing_path):
            if thing.split('.')[1] in valid_types:
                fonts.addApplicationFont(thing_path)
Beispiel #3
0
def install_fonts():
    database = QtGui.QFontDatabase()
    fonts = [
        "opensans/OpenSans-Bold.ttf", "opensans/OpenSans-BoldItalic.ttf",
        "opensans/OpenSans-ExtraBold.ttf",
        "opensans/OpenSans-ExtraBoldItalic.ttf",
        "opensans/OpenSans-Italic.ttf", "opensans/OpenSans-Light.ttf",
        "opensans/OpenSans-LightItalic.ttf", "opensans/OpenSans-Regular.ttf",
        "opensans/OpenSans-Semibold.ttf",
        "opensans/OpenSans-SemiboldItalic.ttf",
        "fontawesome/fontawesome-webfont.ttf"
    ]

    for font in fonts:
        path = util.get_asset("font", font)

        # TODO(marcus): Check if they are already installed first.
        # In hosts, this will be called each time the GUI is shown,
        # potentially installing a font each time.
        if database.addApplicationFont(path) < 0:
            print("Could not install %s\n" % path)
        else:
            print("Installed %s\n" % font)
Beispiel #4
0
        subprocess.Popen([r'C:\Program Files\Blender Foundation\Blender\blender.exe'])

    def launch_command_shell(self):

        self.ui.statusbar.showMessage(':: Launching command shell console ...')
        os.system('START cmd.exe')


if __name__ == "__main__":

    app = QtWidgets.QApplication(sys.argv)

    # Need to create QtGui.QFontDatabase BEFORE setting style sheet that contains
    # fonts from the system
    #
    font_db = QtGui.QFontDatabase()
    orig_font_fam_list = font_db.families()[:]

    # Add Title font
    font_db.addApplicationFont( 'fonts/Merriweather_Sans/MerriweatherSans-Regular.ttf' );
    font_db.addApplicationFont( 'fonts/Merriweather_Sans/MerriweatherSans-Bold.ttf' );

    # Add Body Text font
    font_db.addApplicationFont( 'fonts/Open_Sans/OpenSans-Regular.ttf' );
    font_db.addApplicationFont( 'fonts/Open_Sans/OpenSans-Italic.ttf' );
    font_db.addApplicationFont( 'fonts/Open_Sans/OpenSans-Bold.ttf' );
    font_db.addApplicationFont( 'fonts/Open_Sans/OpenSans-BoldItalic.ttf' );

    # Add Optional Body Text font
    font_db.addApplicationFont( 'fonts/Montserrat/Montserrat-Regular.ttf' );
    font_db.addApplicationFont( 'fonts/Montserrat/Montserrat-Italic.ttf' );