修复BuildImage类text居中类型bug;修复原神今日素材有时发不出图片的问题 #1317
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修复BuildImage类text居中类型bug
问题概括:不应该对字符串对象
text
直接self.getsize(text)
。因为含\n
的字符串在展示(发送出去)后是会分行的,而这样直接self.getsize(text)
获得的是总长度和高度。以致于ttf_w
过长,ttf_h
过短,最终导致居中类型根据此数据计算出的w
、h
错误。图片说明:
修改前,
w
过小(甚至为负),h
过大,导致文字位置不合理(文字的右下部分在图片左下角)。修改后,恢复正常。
修改说明:原代码是通过整张图片大小乘以某个百分比计算出的文字位置,并非真正居中。而居中功能出现bug,通过将文字大小分行(按
\n
划分)计算即可解决。修复原神今日素材有时发不出图片的问题
问题概括:貌似只是Message的构造方式有问题,不过顺便精细了一下其它内容。