-
Notifications
You must be signed in to change notification settings - Fork 39
Add line_spacing property and change (0,0) definition #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f5866a5
Align text to bottom left corner
ladyada c64562f
line spacer property
ladyada a8b02b0
demo for bounding box
ladyada 630d199
removed old example. calculate bounding box during text render
ladyada 9ab53c1
add boundingbox test
ladyada c31a9ab
lint
ladyada 9de1017
account for dx in font glyphs, change width/height to max_glyphs (whi…
ladyada 566611c
fix docstr
ladyada 950ef06
move to label
ladyada 73aaa01
add comment
ladyada 2cb0c29
fix example code
ladyada bc3b3b1
fix example
ladyada c38e582
fix autodoc subfile
ladyada 8673868
last tyyyyyyyyyyyyyyyyypo
ladyada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import os | ||
import board | ||
import displayio | ||
from adafruit_display_text.label import Label | ||
from adafruit_bitmap_font import bitmap_font | ||
|
||
# the current working directory (where this file is) | ||
cwd = ("/"+__file__).rsplit('/', 1)[0] | ||
fonts = [file for file in os.listdir(cwd+"/fonts/") | ||
if (file.endswith(".bdf") and not file.startswith("._"))] | ||
for i, filename in enumerate(fonts): | ||
fonts[i] = cwd+"/fonts/"+filename | ||
print(fonts) | ||
|
||
########################################################################## | ||
THE_FONT = fonts[0] | ||
DISPLAY_STRING = "A multi-line-\nexample of\n font bounding!" | ||
WRAP_CHARS = 40 | ||
|
||
########################################################################## | ||
# Make the display context | ||
splash = displayio.Group() | ||
board.DISPLAY.show(splash) | ||
|
||
# Make a background color fill | ||
color_bitmap = displayio.Bitmap(320, 240, 1) | ||
color_palette = displayio.Palette(1) | ||
color_palette[0] = 0xFFFFFF | ||
bg_sprite = displayio.TileGrid(color_bitmap, | ||
pixel_shader=color_palette, | ||
position=(0, 0)) | ||
splash.append(bg_sprite) | ||
|
||
# Load the font | ||
font = bitmap_font.load_font(THE_FONT) | ||
font.load_glyphs(DISPLAY_STRING.encode('utf-8')) | ||
|
||
print(DISPLAY_STRING) | ||
|
||
text = Label(font, text=DISPLAY_STRING) | ||
text.x = 20 | ||
text.y = 100 | ||
text.color = 0x0 | ||
|
||
# Make a background color fill | ||
dims = text.bounding_box | ||
print(dims) | ||
textbg_bitmap = displayio.Bitmap(dims[2], dims[3], 1) | ||
textbg_palette = displayio.Palette(1) | ||
textbg_palette[0] = 0xFF0000 | ||
textbg_sprite = displayio.TileGrid(textbg_bitmap, | ||
pixel_shader=textbg_palette, | ||
position=(text.x+dims[0], text.y+dims[1])) | ||
splash.append(textbg_sprite) | ||
splash.append(text) | ||
board.DISPLAY.refresh_soon() | ||
board.DISPLAY.wait_for_frame() | ||
|
||
|
||
while True: | ||
pass |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.