Skip to content

Commit 2dbcad5

Browse files
committed
adding font with license file. fixed example script for built-in screens.
1 parent 92733f5 commit 2dbcad5

6 files changed

+12631
-4240
lines changed

LICENSES/OFL-1.1.txt

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
Copyright (c) 2016-2020, Tyler Finck <hi@tylerfinck.com>
2+
3+
Copyright (c) 2014, Micah Rich <micah@micahrich.com>,
4+
with Reserved Font Name: "League Spartan".
5+
6+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
7+
This license is copied below, and is also available with a FAQ at:
8+
http://scripts.sil.org/OFL
9+
10+
Version 1.1 - 26 February 2007
11+
12+
----
13+
14+
SIL Open Font License
15+
=====================
16+
17+
18+
Preamble
19+
--------
20+
21+
The goals of the Open Font License (OFL) are to stimulate worldwide
22+
development of collaborative font projects, to support the font creation
23+
efforts of academic and linguistic communities, and to provide a free and
24+
open framework in which fonts may be shared and improved in partnership
25+
with others.
26+
27+
The OFL allows the licensed fonts to be used, studied, modified and
28+
redistributed freely as long as they are not sold by themselves. The
29+
fonts, including any derivative works, can be bundled, embedded,
30+
redistributed and/or sold with any software provided that any reserved
31+
names are not used by derivative works. The fonts and derivatives,
32+
however, cannot be released under any other type of license. The
33+
requirement for fonts to remain under this license does not apply
34+
to any document created using the fonts or their derivatives.
35+
36+
Definitions
37+
-----------
38+
39+
`"Font Software"` refers to the set of files released by the Copyright
40+
Holder(s) under this license and clearly marked as such. This may
41+
include source files, build scripts and documentation.
42+
43+
`"Reserved Font Name"` refers to any names specified as such after the
44+
copyright statement(s).
45+
46+
`"Original Version"` refers to the collection of Font Software components as
47+
distributed by the Copyright Holder(s).
48+
49+
`"Modified Version"` refers to any derivative made by adding to, deleting,
50+
or substituting -- in part or in whole -- any of the components of the
51+
Original Version, by changing formats or by porting the Font Software to a
52+
new environment.
53+
54+
`"Author"` refers to any designer, engineer, programmer, technical
55+
writer or other person who contributed to the Font Software.
56+
57+
Permission & Conditions
58+
-----------------------
59+
60+
Permission is hereby granted, free of charge, to any person obtaining
61+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
62+
redistribute, and sell modified and unmodified copies of the Font
63+
Software, subject to the following conditions:
64+
65+
1. Neither the Font Software nor any of its individual components,
66+
in Original or Modified Versions, may be sold by itself.
67+
68+
2. Original or Modified Versions of the Font Software may be bundled,
69+
redistributed and/or sold with any software, provided that each copy
70+
contains the above copyright notice and this license. These can be
71+
included either as stand-alone text files, human-readable headers or
72+
in the appropriate machine-readable metadata fields within text or
73+
binary files as long as those fields can be easily viewed by the user.
74+
75+
3. No Modified Version of the Font Software may use the Reserved Font
76+
Name(s) unless explicit written permission is granted by the corresponding
77+
Copyright Holder. This restriction only applies to the primary font name as
78+
presented to the users.
79+
80+
4. The name(s) of the Copyright Holder(s) or the Author(s) of the Font
81+
Software shall not be used to promote, endorse or advertise any
82+
Modified Version, except to acknowledge the contribution(s) of the
83+
Copyright Holder(s) and the Author(s) or with their explicit written
84+
permission.
85+
86+
5. The Font Software, modified or unmodified, in part or in whole,
87+
must be distributed entirely under this license, and must not be
88+
distributed under any other license. The requirement for fonts to
89+
remain under this license does not apply to any document created
90+
using the Font Software.
91+
92+
Termination
93+
-----------
94+
95+
This license becomes null and void if any of the above conditions are
96+
not met.
97+
98+
Disclaimer
99+
----------
100+
101+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
102+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
103+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
104+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
105+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
106+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
107+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
108+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
109+
OTHER DEALINGS IN THE FONT SOFTWARE.

examples/display_text_background_color_padding.py

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,70 @@
55
import board
66
import displayio
77

8-
9-
# from adafruit_st7789 import ST7789
10-
from adafruit_ili9341 import ILI9341
118
from adafruit_bitmap_font import bitmap_font
129
from adafruit_display_text import label
1310

14-
# Setup the SPI display
15-
16-
print("Starting the display...") # goes to serial only
17-
displayio.release_displays()
18-
19-
20-
spi = board.SPI()
21-
tft_cs = board.D9 # arbitrary, pin not used
22-
tft_dc = board.D10
23-
tft_backlight = board.D12
24-
tft_reset = board.D11
2511

26-
while not spi.try_lock():
27-
spi.configure(baudrate=32000000)
28-
spi.unlock()
29-
30-
display_bus = displayio.FourWire(
31-
spi,
32-
command=tft_dc,
33-
chip_select=tft_cs,
34-
reset=tft_reset,
35-
baudrate=32000000,
36-
polarity=1,
37-
phase=1,
38-
)
12+
# Setup the SPI display
13+
if "DISPLAY" in dir(board):
14+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
15+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
16+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
17+
display = board.DISPLAY
18+
19+
else:
20+
print("Starting external display") # goes to serial only
21+
# Setup the LCD display with driver
22+
# You may need to change this to match the display driver for the chipset
23+
# used on your display
24+
from adafruit_ili9341 import ILI9341
25+
26+
# from adafruit_st7789 import ST7789
27+
28+
displayio.release_displays()
29+
30+
# setup the SPI bus
31+
spi = board.SPI()
32+
tft_cs = board.D9 # arbitrary, pin not used
33+
tft_dc = board.D10
34+
tft_backlight = board.D12
35+
tft_reset = board.D11
36+
37+
while not spi.try_lock():
38+
spi.configure(baudrate=32000000)
39+
spi.unlock()
40+
41+
display_bus = displayio.FourWire(
42+
spi,
43+
command=tft_dc,
44+
chip_select=tft_cs,
45+
reset=tft_reset,
46+
baudrate=32000000,
47+
polarity=1,
48+
phase=1,
49+
)
3950

40-
print("spi.frequency: {}".format(spi.frequency))
51+
# Number of pixels in the display
52+
DISPLAY_WIDTH = 320
53+
DISPLAY_HEIGHT = 240
4154

42-
DISPLAY_WIDTH = 320
43-
DISPLAY_HEIGHT = 240
55+
# display = ST7789(display_bus, width=240, height=240, rotation=0, rowstart=80, colstart=0)
4456

45-
# display = ST7789(display_bus, width=240, height=240, rotation=0, rowstart=80, colstart=0)
46-
display = ILI9341(
47-
display_bus,
48-
width=DISPLAY_WIDTH,
49-
height=DISPLAY_HEIGHT,
50-
rotation=180,
51-
auto_refresh=True,
52-
)
57+
# create the display
58+
display = ILI9341(
59+
display_bus,
60+
width=DISPLAY_WIDTH,
61+
height=DISPLAY_HEIGHT,
62+
rotation=180, # The rotation can be adjusted to match your configuration.
63+
auto_refresh=True,
64+
native_frames_per_second=90,
65+
)
5366

5467
display.show(None)
5568

5669
# font=terminalio.FONT # this is the Builtin fixed dimension font
5770

58-
font = bitmap_font.load_font("fonts/Helvetica-Bold-16.bdf")
59-
71+
font = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf")
6072

6173
text = []
6274
text.append("none") # no ascenders or descenders

examples/display_text_label_vs_bitmap_label_comparison.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,20 @@
2929
fontList = []
3030

3131
# Load some proportional fonts
32-
fontFile = "fonts/Helvetica-Bold-16.bdf"
32+
fontFile = "fonts/LeagueSpartan-Bold-16.bdf"
3333
fontToUse = bitmap_font.load_font(fontFile)
3434

3535
# Set scaling factor for display text
3636
my_scale = 1
3737

3838
# Setup the SPI display
39-
if "DISPLAY" not in dir(board):
39+
if "DISPLAY" in dir(board):
40+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
41+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
42+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
43+
display = board.DISPLAY
44+
45+
else:
4046
# Setup the LCD display with driver
4147
# You may need to change this to match the display driver for the chipset
4248
# used on your display
@@ -81,13 +87,9 @@
8187

8288
# reset the display to show nothing.
8389
display.show(None)
84-
else:
85-
# built-in display
86-
display = board.DISPLAY
8790

8891
print("Display is started")
8992

90-
9193
preload_glyphs = (
9294
True # set this to True if you want to preload the font glyphs into memory
9395
)

0 commit comments

Comments
 (0)