Skip to content

anchor_point and anchored_position do not work well with scale #55

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

Closed
kevinjwalters opened this issue Jun 27, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@kevinjwalters
Copy link

I updated my libraries (from adafruit-circuitpython-bundle-5.x-mpy-20200625) and tried this,

Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit CLUE nRF52840 Express with nRF52840
>>> import terminalio, displayio, board
>>> from adafruit_display_text import label
>>> text_area = label.Label(terminalio.FONT, text="Scale!", scale=5, color=0xc0c0c0)
>>> board.DISPLAY.show(text_area)
>>> text_area.anchor_point
(0, 0)
>>> text_area.anchored_position
(0, -7)
>>> text_area.anchored_position = (0, 0)  ### expectation is text will be on screen at top left

The position of that text is not entirely on screen, the top is chopped off. This is presumably due to issues with a scale which isn't the default value of 1. Discussed this a little bit recently with @FoamyGuy in Discord.

@FoamyGuy
Copy link
Contributor

I think the root of this issue is that the scale=5 parameter doesn't really belong to the Label, and Label isn't taking it into account for anything or really doing anything with it, except passing it through to the super class Group __init__() here:

super().__init__(max_size=max_glyphs + 1, **kwargs)

using some arcane pythonic magic involving **kwargs

I think in order for anchor_point and anchored_position to play nicely with scaled text we need to capture the scale factor and keep it inside of Label and use it to when we calculate the new location.

I will try to take an attempt at making these changes.

@makermelissa
Copy link
Collaborator

Fixed by #57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants