mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-05 20:00:04 +08:00
修复首次签到时使用道具后签到报错
This commit is contained in:
@@ -456,7 +456,7 @@ class BuildImage:
|
||||
说明:
|
||||
在图片上添加文字
|
||||
参数:
|
||||
:param pos: 文字位置
|
||||
:param pos: 文字位置(使用center_type中的center后会失效,使用by_width后x失效,使用by_height后y失效)
|
||||
:param text: 文字内容
|
||||
:param fill: 文字颜色
|
||||
:param center_type: 居中类型,可能的值 center: 完全居中,by_width: 水平居中,by_height: 垂直居中
|
||||
@@ -469,7 +469,12 @@ class BuildImage:
|
||||
"center_type must be 'center', 'by_width' or 'by_height'"
|
||||
)
|
||||
w, h = self.w, self.h
|
||||
ttf_w, ttf_h = self.getsize(text)
|
||||
longgest_text = ''
|
||||
sentence = text.split("\n")
|
||||
for x in sentence:
|
||||
longgest_text = x if len(x) > len(longgest_text) else longgest_text
|
||||
ttf_w, ttf_h = self.getsize(longgest_text)
|
||||
ttf_h = ttf_h * len(sentence)
|
||||
if center_type == "center":
|
||||
w = int((w - ttf_w) / 2)
|
||||
h = int((h - ttf_h) / 2)
|
||||
|
||||
Reference in New Issue
Block a user