AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug]本地图片渲染没有安装对应字体会报错

Open kterna opened this issue 1 year ago • 3 comments

发生了什么

调用astrbot自身文字渲染成图片时,如果没有成功连接上在线渲染,使用本地渲染时没有安装local_strategy.py中指定的font时,就会报错'NoneType' object has no attribute 'getsize' 参考文献:https://github.com/kterna/astrbot_plugin_liferestart/issues/1

如何复现?

  1. 一个比较垃圾的网络
  2. 调用一些使用astrbot图片渲染的插件

AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

latest

操作系统

Windows

报错日志

[13:48:13] [Core] [INFO] [core.event_bus:21]: [aiocqhttp] tuanzi/243938151: /重开 [13:48:15] [Core] [ERRO] [t2i.renderer:41]: Failed to render image via AstrBot API: 500, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url='https://t2i.soulter.top/text2img/generate'. Falling back to local rendering. [13:48:15] [Plug] [INFO] [astrbot_plugin_comp_entertainment.main:576]: 非LLM消息,pass [13:48:15] [Core] [INFO] [respond.stage:110]: AstrBot -> tuanzi/243938151: 发生错误:'NoneType' object has no attribute 'getsize'

你愿意提交 PR 吗?

  • [x] 是的,我愿意提交 PR!

Code of Conduct

  • [x] 我已阅读并同意遵守该项目的 行为准则。

kterna avatar Mar 24 '25 06:03 kterna

最新 Commit 已经修复,允许在 data/ 目录下放置自定义的中文字体,命名为 font.ttf。

并且显著优化了本地渲染 Markdown 的效果。

Image

Soulter avatar Mar 25 '25 03:03 Soulter

Image 现在的 这个 MD 转图片经常出问题,准备放弃使用了,或者说是在服务器部署一个能提供 API 的文本转图片的。

constansino avatar Dec 29 '25 06:12 constansino

Image 遇到了同样的问题

whossyourrddady avatar Feb 25 '26 16:02 whossyourrddady