Skip to content

Commit 8f20ef3

Browse files
committed
New Demo - Demo_Fonts_Using_pyglet - adding fonts to tkinter using pyglet (thanks Jason!)
1 parent d52dd0e commit 8f20ef3

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pyglet
2+
import PySimpleGUI as sg
3+
4+
"""
5+
Demo - Using pyglet to get custom fonts into PySimpleGUI
6+
7+
Original code by @jason990420
8+
9+
Copyright 2022 PySimpleGUI
10+
11+
Font information:
12+
Copyright (c) 2020, Walter E Stewart,
13+
with Reserved Font Name Open Flame.
14+
https://www.1001freefonts.com/open-flame.font
15+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
16+
This license is copied below, and is also available with a FAQ at:
17+
http://scripts.sil.org/OFL
18+
"""
19+
20+
pyglet.font.add_file(r".\OpenFlame.ttf")
21+
22+
font1 = ("Open Flame", 40) # Note - use the font "face name" not the filename when specifying the font
23+
font2 = ("Courier New", 40)
24+
font3 = ("Helvetica", 40)
25+
text_string = "ABCDEFG abcdefg 1234567890"
26+
27+
layout = [ [sg.Text(text_string, font=font1)],
28+
[sg.Text(text_string, font=font2)],
29+
[sg.Text(text_string, font=font3)] ]
30+
31+
window = sg.Window('Adding Fonts', layout)
32+
33+
while True:
34+
event, values = window.read()
35+
if event == sg.WINDOW_CLOSED:
36+
break
37+
38+
window.close()

DemoPrograms/OpenFlame.ttf

418 KB
Binary file not shown.

0 commit comments

Comments
 (0)