adafruit / adafruit/Adafruit_CircuitPython_Display_Text

Height Difference Between Label and BitmapLabel

Open
#214 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
65
Forks
39
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied CircuitPython script and compare the sizes and anchored positions of bitmap_label.Label and label.Label with background_tight=False. Read the implementations of these two label classes and investigate how their background bounds account for ascenders and descenders. Done means both labels produce consistent heights and align at the same anchor position.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.