Skip to content

y position of text can be wrong if constructor does not specify text #80

Closed
@kevinjwalters

Description

@kevinjwalters

I updated my libraries last night to ones from adafruit-circuitpython-bundle-5.x-mpy-20200806.zip. I noticed the performance improvement with moving around text but I also spotted one solitary piece of text that was misplaced slightly off screen.

I've just made a simple recreation of this, I think it's when text is not specified or it is empty string, y is set, and then text is set. I am using scaled text here.

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit CLUE nRF52840 Express with nRF52840
>>>
>>> import displayio, terminalio, board
>>> from adafruit_display_text.label import Label
>>> fdim = terminalio.FONT.get_bounding_box()
>>> l1 = Label(terminalio.FONT, max_glyphs=9, scale=3, color=0xff0000)
>>> l2 = Label(terminalio.FONT, text="", max_glyphs=9, scale=3, color=0x00ff00)
>>> l3 = Label(terminalio.FONT, text="Chad", max_glyphs=9, scale=3, color=0x0000ff)
>>> l1.y = l2.y = l3.y = round(240 - (3 * fdim[1] / 2))
>>> (l1.y, l2.y, l3.y)
(219, 219, 219)
>>> l2.x = 80
>>> l3.x = 160
>>> tg = displayio.Group(max_size=3)
>>> tg.append(l1)
>>> tg.append(l2)
>>> tg.append(l3)
>>> board.DISPLAY.show(tg)
>>> l1.text="Wot"
>>> l2.text="No"
>>> (l1.y, l2.y, l3.y)
(240, 240, 219)

Only l3 is correctly position, l1 and l2 are half off screen.

I see #78 which sounds like it could be in the same area?

Setting to whitespace seems to be a workaround for me, e.g. text=" ", and might be able to re-order my code to set text once in constructor.

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