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

Do not remove anchor when drawing multiline text #180

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

jhbruhn
Copy link
Contributor

@jhbruhn jhbruhn commented Oct 5, 2024

I am not sure why this was done in the first place, maybe because support for it was only added in Pillow v8? This way, multiline text can properly be drawn if for example the text is fully centered.

I am not sure why this was done in the first place, maybe because support for it was only added in Pillow v8? This way, multiline text can properly be drawn if for example the text is fully centered.
@g4bri3lDev g4bri3lDev merged commit d7b9fba into OpenEPaperLink:main Oct 5, 2024
2 checks passed
@jterrace
Copy link
Contributor

jterrace commented Oct 9, 2024

After this change, I'm getting:

"HomeAssistantError: anchor not supported for multiline text"

with a payload of:

type: "text",
value: "....",
font: "rbm.ttf",
x: 0,
y_padding: 5,
size: 20,
color: "black",
max_width: 296

which was previously working?

@jterrace
Copy link
Contributor

jterrace commented Oct 9, 2024

Looks like it's because the default anchor is lt:
https://github.com/OpenEPaperLink/Home_Assistant_Integration/blob/main/custom_components/open_epaper_link/imagegen.py#L220

and t is only supported for single line text: https://pillow.readthedocs.io/en/stable/handbook/text-anchors.html#vertical-anchor-alignment

I fixed it by explicitly setting anchor to la instead of defaulting to la. I think the default anchor should probably be switched to la instead of lt, since a is the same as t for single line text but will also work for multiline text.

jterrace added a commit to jterrace/open_epaper_link_homeassistant that referenced this pull request Oct 9, 2024
@jterrace
Copy link
Contributor

jterrace commented Oct 9, 2024

Sent out #181

@jhbruhn
Copy link
Contributor Author

jhbruhn commented Oct 9, 2024

Oops, nice catch :)

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

Successfully merging this pull request may close these issues.

3 participants