Closed jhbruhn closed 1 month ago
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?
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.
Oops, nice catch :)
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.