Skip to content
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

Height Difference Between Label and BitmapLabel #214

Open
FoamyGuy opened this issue Nov 14, 2024 · 0 comments
Open

Height Difference Between Label and BitmapLabel #214

FoamyGuy opened this issue Nov 14, 2024 · 0 comments

Comments

@FoamyGuy
Copy link
Contributor

when background_tight=False BitmapLabel and Label arrive at different sizes for their heights.

This is easy to see visually with this script:

import board
import displayio
from adafruit_display_text_pr import bitmap_label, label
from terminalio import FONT
from font_league_script_number_one_webfont_72_latin1 import FONT as LEAGUE_SCRIPT

main_group = displayio.Group()
text = "ABCDFGg"
text_area = bitmap_label.Label(LEAGUE_SCRIPT, text=text, base_alignment=True, background_tight=False,
                               anchor_point=(0.0, 1.0), background_color=0xff00ff,
                               anchored_position=(0, board.DISPLAY.height * 3 // 4))
# text_area.x = 10
# text_area.y = 84
main_group.append(text_area)

text_area_lbl = label.Label(LEAGUE_SCRIPT, text=text, base_alignment=True, background_tight=False,
                            anchor_point=(0.0, 1.0), background_color=0x00ff00,
                            anchored_position=(0, board.DISPLAY.height * 3 // 4))
# text_area_lbl.x = 10
# text_area_lbl.y = 80
main_group.append(text_area_lbl)

board.DISPLAY.root_group = main_group
while True:
    pass

The different labels are intended to be placed at the same location via anchor positioning but end up offset from each other. The BitmapLabel has a much larger area filled for the background and the plain Label has a much smaller area that allows the ascenders and descenders to leak outside of it's supposed bounding box.

This was noted originally in #201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant