Skip to content

Commit 033d83a

Browse files
maad-odooXavier-Do
authored andcommitted
[FIX] web_editor: make heigher pillow version support
Before this commit: We used the .textsize method, which returned the height and width of the icon. However, in the latest version of Pillow, this method was deprecated, resulting in errors in the log. After this commit: We have transitioned to using the textbbox method, which returns the coordinates of the top, left, bottom, and right of the text's bounding box. From these coordinates, we calculate the height and width of the text. task-3502373 X-original-commit: 22c082f
1 parent 0951d88 commit 033d83a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • addons/web_editor/controllers

addons/web_editor/controllers/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def export_icon_to_png(self, icon, color='#000', bg=None, size=100, alpha=255, f
173173
image = Image.new("RGBA", (width, height), color)
174174
draw = ImageDraw.Draw(image)
175175

176-
boxw, boxh = draw.textsize(icon, font=font_obj)
176+
box = draw.textbbox((0, 0), icon, font=font_obj)
177+
boxw = box[2] - box[0]
178+
boxh = box[3] - box[1]
177179
draw.text((0, 0), icon, font=font_obj)
178180
left, top, right, bottom = image.getbbox()
179181

0 commit comments

Comments
 (0)