Skip to content

Commit

Permalink
Quickfix for HA2023.8
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrMachowski authored Aug 5, 2023
1 parent 276a6ee commit 2475e84
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def create_empty_map_image(colors: Colors, text: str = "NO MAP") -> ImageType:
else:
text_color = (255, 255, 255)
draw = ImageDraw.Draw(image, "RGBA")
w, h = draw.textsize(text)
l, t, r, b = draw.textbbox((0, 0), text)
w, h = r - l, b - t
draw.text(((image.size[0] - w) / 2, (image.size[1] - h) / 2), text, fill=text_color)
return image

Expand Down Expand Up @@ -256,7 +257,7 @@ def draw_func(draw: ImageDraw):
point = position.to_img(image.dimensions)
angle = -position.a if position.a is not None else 0
coords = [point.x - r, point.y - r, point.x + r, point.y + r]
draw.pieslice(coords, angle + 90, angle - 90, outline="black", fill=fill)
draw.pieslice(coords, angle + 90, angle - 90, outline=outline, fill=fill)

ImageHandler.__draw_on_new_layer__(image, draw_func, 1, ImageHandler.__use_transparency__(outline, fill))

Expand Down Expand Up @@ -303,7 +304,8 @@ def draw_func(draw: ImageDraw):
except ImportError:
_LOGGER.warning("Unable to open font: %s", font_file)
finally:
w, h = draw.textsize(text, font)
l, t, r, b = draw.textbbox((0, 0), text, font)
w, h = r - l, b - t
draw.text((x - w / 2, y - h / 2), text, font=font, fill=color)

ImageHandler.__draw_on_new_layer__(image, draw_func, 1, ImageHandler.__use_transparency__(color))
Expand Down

0 comments on commit 2475e84

Please sign in to comment.