Skip to content

Height Difference Between Label and BitmapLabel #214

Open
@FoamyGuy

Description

@FoamyGuy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions