noneplugin / nonebot-plugin-memes

Nonebot2 表情包制作插件
MIT License
230 stars 20 forks source link

执行"举牌 🤺"时报错 #35

Closed coder-tq closed 1 year ago

coder-tq commented 1 year ago

emoji标签会出现这个报错 02-19 12:00:01 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_memes) failed. Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run await handler( File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 104, in call values = await self.solve(kwargs) File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 219, in solve values = await asyncio.gather( File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 208, in _solve_field value = await cast(Param, field.field_info)._solve(params) File "/usr/local/lib/python3.10/site-packages/nonebot/internal/params.py", line 148, in _solve return await task File "/usr/local/lib/python3.10/site-packages/nonebot/utils.py", line 113, in _wrapper result = await loop.run_in_executor(None, pfunc) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_memes/normal_memes.py", line 317, in raisesign text_img.draw_text( File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_imageutils/build_image.py", line 497, in draw_text text2img.draw_on_image(self.image, (int(x), int(y))) File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_imageutils/text2image.py", line 429, in draw_on_image char.draw_on(img, (int(x), int(y))) File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_imageutils/text2image.py", line 67, in draw_on draw.text( File "/usr/local/lib/python3.10/site-packages/PIL/ImageDraw.py", line 520, in text draw_text(ink) File "/usr/local/lib/python3.10/site-packages/PIL/ImageDraw.py", line 463, in draw_text mask, offset = font.getmask2( File "/usr/local/lib/python3.10/site-packages/PIL/ImageFont.py", line 778, in getmask2 self.font.render( OSError: SVG hooks have not been set

coder-tq commented 1 year ago

系统centos7,字体Noto Color Emoji.ttf

MeetWq commented 1 year ago

字体有问题,不能用SVG的字体

coder-tq commented 1 year ago

我可以在哪里下载到非svg版本的Noto Color Emoji字体呢

MeetWq commented 1 year ago

https://github.com/googlefonts/noto-emoji/blob/main/fonts/NotoColorEmoji.ttf

coder-tq commented 1 year ago

https://github.com/googlefonts/noto-emoji/blob/main/fonts/NotoColorEmoji.ttf

02-19 14:01:30 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_memes) failed. Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run await handler( File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 104, in call values = await self.solve(kwargs) File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 219, in solve values = await asyncio.gather( File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 208, in _solve_field value = await cast(Param, field.field_info)._solve(params) File "/usr/local/lib/python3.10/site-packages/nonebot/internal/params.py", line 148, in _solve return await task File "/usr/local/lib/python3.10/site-packages/nonebot/utils.py", line 113, in _wrapper result = await loop.run_in_executor(None, pfunc) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_memes/normal_memes.py", line 317, in raisesign text_img.draw_text( File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_imageutils/build_image.py", line 479, in draw_text text2img = Text2Image.from_text( File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_imageutils/text2image.py", line 201, in from_text chars.append(Char(char, font, fontsize, fill, stroke_width, stroke_fill)) File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_imageutils/text2image.py", line 34, in init self.pilfont = self.font.load_font(fontsize) File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_imageutils/fonts.py", line 147, in load_font return ImageFont.truetype(str(self.path), fontsize, encoding="utf-8") File "/usr/local/lib/python3.10/site-packages/PIL/ImageFont.py", line 1008, in truetype return freetype(font) File "/usr/local/lib/python3.10/site-packages/PIL/ImageFont.py", line 1005, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/usr/local/lib/python3.10/site-packages/PIL/ImageFont.py", line 255, in init self.font = core.getfont( OSError: invalid pixel size

变成新的报错了

MeetWq commented 1 year ago

你的字体是怎么装的?名字有没有改过?

coder-tq commented 1 year ago

改过字体文件的名字与配置中一致,丢到/data/fonts文件夹

coder-tq commented 1 year ago

invalid pixel size

https://github.com/python-pillow/Pillow/issues/6166 找到了相关的issue,我需要修改什么么

MeetWq commented 1 year ago

字体名需要是 NotoColorEmoji.ttf