[bugfix] Overlay: Fix the error 'TypeError:’float’ object cannot be interpreted as an integer'
改行が必要なくらいの長さのテキストを表示しようとするときに出るエラー。計算時、int型に強制変換して修正。
This commit is contained in:
@@ -68,7 +68,7 @@ class OverlayImage:
|
|||||||
|
|
||||||
text_width = draw.textlength(text, font)
|
text_width = draw.textlength(text, font)
|
||||||
character_width = text_width // len(text)
|
character_width = text_width // len(text)
|
||||||
character_line_num = (base_width // character_width) - 12
|
character_line_num = int((base_width // character_width) - 12)
|
||||||
if len(text) > character_line_num:
|
if len(text) > character_line_num:
|
||||||
text = "\n".join([text[i:i + character_line_num] for i in range(0, len(text), character_line_num)])
|
text = "\n".join([text[i:i + character_line_num] for i in range(0, len(text), character_line_num)])
|
||||||
text_height = font_size * (len(text.split("\n")) + 1) + 20
|
text_height = font_size * (len(text.split("\n")) + 1) + 20
|
||||||
|
|||||||
Reference in New Issue
Block a user