New Demo - Demo_Fonts_Using_pyglet - adding fonts to tkinter using pyglet (thanks Jason!)

This commit is contained in:
PySimpleGUI 2022-02-14 13:37:09 -05:00
parent d52dd0eb85
commit 8f20ef32ca
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
import pyglet
import PySimpleGUI as sg
"""
Demo - Using pyglet to get custom fonts into PySimpleGUI
Original code by @jason990420
Copyright 2022 PySimpleGUI
Font information:
Copyright (c) 2020, Walter E Stewart,
with Reserved Font Name Open Flame.
https://www.1001freefonts.com/open-flame.font
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
"""
pyglet.font.add_file(r".\OpenFlame.ttf")
font1 = ("Open Flame", 40) # Note - use the font "face name" not the filename when specifying the font
font2 = ("Courier New", 40)
font3 = ("Helvetica", 40)
text_string = "ABCDEFG abcdefg 1234567890"
layout = [ [sg.Text(text_string, font=font1)],
[sg.Text(text_string, font=font2)],
[sg.Text(text_string, font=font3)] ]
window = sg.Window('Adding Fonts', layout)
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
window.close()

BIN
DemoPrograms/OpenFlame.ttf Normal file

Binary file not shown.