Skip to content

Commit cf60390

Browse files
authored
Merge pull request #8 from dastels/master
Move font into a fonts directory in the game directories.
2 parents 93c1013 + 321c862 commit cf60390

File tree

3 files changed

+6156
-19
lines changed

3 files changed

+6156
-19
lines changed

adafruit_pyoa.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,6 @@ def __init__(self):
7272
self._button_group = displayio.Group(max_size=2)
7373
self.root_group.append(self._button_group)
7474

75-
self._text_font = bitmap_font.load_font("Arial-Bold-12.bdf")
76-
#self._text_font = fontio.BuiltinFont
77-
try:
78-
glyphs = b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!,. "\'?!'
79-
print("Preloading font glyphs:", glyphs)
80-
self._text_font.load_glyphs(glyphs)
81-
except AttributeError:
82-
pass # normal for built in font
83-
84-
self._left_button = Button(x=10, y=195, width=120, height=40,
85-
label="Left", label_font=self._text_font,
86-
style=Button.SHADOWROUNDRECT)
87-
self._right_button = Button(x=190, y=195, width=120, height=40,
88-
label="Right", label_font=self._text_font,
89-
style=Button.SHADOWROUNDRECT)
90-
self._middle_button = Button(x=100, y=195, width=120, height=40,
91-
label="Middle", label_font=self._text_font,
92-
style=Button.SHADOWROUNDRECT)
93-
9475
self._speaker_enable = DigitalInOut(board.SPEAKER_ENABLE)
9576
self._speaker_enable.switch_to_output(False)
9677
self.audio = audioio.AudioOut(board.AUDIO_OUT)
@@ -112,6 +93,10 @@ def __init__(self):
11293
self._game = None
11394
self._text = None
11495
self._background_sprite = None
96+
self._text_font = None
97+
self._left_button = None
98+
self._right_button = None
99+
self._middle_button = None
115100

116101

117102
def load_game(self, game_directory):
@@ -121,6 +106,27 @@ def load_game(self, game_directory):
121106
122107
"""
123108
self._gamedirectory = game_directory
109+
110+
self._text_font = bitmap_font.load_font(game_directory+"/fonts/Arial-Bold-12.bdf")
111+
#self._text_font = fontio.BuiltinFont
112+
try:
113+
glyphs = b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!,. "\'?!'
114+
print("Preloading font glyphs:", glyphs)
115+
self._text_font.load_glyphs(glyphs)
116+
except AttributeError:
117+
pass # normal for built in font
118+
119+
self._left_button = Button(x=10, y=195, width=120, height=40,
120+
label="Left", label_font=self._text_font,
121+
style=Button.SHADOWROUNDRECT)
122+
self._right_button = Button(x=190, y=195, width=120, height=40,
123+
label="Right", label_font=self._text_font,
124+
style=Button.SHADOWROUNDRECT)
125+
self._middle_button = Button(x=100, y=195, width=120, height=40,
126+
label="Middle", label_font=self._text_font,
127+
style=Button.SHADOWROUNDRECT)
128+
129+
124130
self._gamefilename = game_directory+"/cyoa.json"
125131
try:
126132
game_file = open(self._gamefilename, "r")
File renamed without changes.

0 commit comments

Comments
 (0)