补全 Emoji 显示和另一个显示
This commit is contained in:
@ -1,6 +1,12 @@
|
||||
from imagetext_py import FontDB
|
||||
from imagetext_py import EmojiOptions, FontDB
|
||||
|
||||
from .path import assets
|
||||
from .path import ASSETS
|
||||
|
||||
FontDB.LoadFromDir(str(ASSETS))
|
||||
|
||||
FontDB.SetDefaultEmojiOptions(EmojiOptions(
|
||||
parse_shortcodes=False,
|
||||
))
|
||||
|
||||
FontDB.LoadFromDir(str(assets))
|
||||
HARMONYOS_SANS_SC_BLACK = FontDB.Query("HarmonyOS_Sans_SC_Black")
|
||||
HARMONYOS_SANS_SC_REGULAR = FontDB.Query("HarmonyOS_Sans_SC_Regular")
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
from pathlib import Path
|
||||
|
||||
assets = Path(__file__).parent.parent.parent / "assets"
|
||||
ASSETS = Path(__file__).parent.parent.parent / "assets"
|
||||
|
||||
@ -5,9 +5,9 @@ import imagetext_py
|
||||
import PIL.Image
|
||||
|
||||
from .base.fonts import HARMONYOS_SANS_SC_BLACK
|
||||
from .base.path import assets
|
||||
from .base.path import ASSETS
|
||||
|
||||
geimao_image = PIL.Image.open(assets / "geimao.jpg").convert("RGBA")
|
||||
geimao_image = PIL.Image.open(ASSETS / "geimao.jpg").convert("RGBA")
|
||||
|
||||
|
||||
def _draw_geimao(saying: str):
|
||||
@ -20,6 +20,7 @@ def _draw_geimao(saying: str):
|
||||
imagetext_py.TextAlign.Center,
|
||||
cast(Any, 30.0),
|
||||
imagetext_py.Paint.Color(imagetext_py.Color.from_hex("FFFFFFFF")),
|
||||
draw_emojis=True,
|
||||
)
|
||||
return img
|
||||
|
||||
|
||||
26
konabot/plugins/memepack/drawing/pt.py
Normal file
26
konabot/plugins/memepack/drawing/pt.py
Normal file
@ -0,0 +1,26 @@
|
||||
import asyncio
|
||||
|
||||
import imagetext_py
|
||||
import PIL.Image
|
||||
|
||||
from .base.fonts import HARMONYOS_SANS_SC_REGULAR
|
||||
from .base.path import ASSETS
|
||||
|
||||
pt_image = PIL.Image.open(ASSETS / "ptsay.png").convert("RGBA")
|
||||
|
||||
|
||||
def _draw_pt(saying: str):
|
||||
img = pt_image.copy()
|
||||
with imagetext_py.Writer(img) as iw:
|
||||
iw.draw_text_wrapped(
|
||||
saying, 259, 278, 0.5, 0.5, 360, 48, HARMONYOS_SANS_SC_REGULAR,
|
||||
imagetext_py.Paint.Color(imagetext_py.Color.from_hex("000000FF")),
|
||||
1.0,
|
||||
imagetext_py.TextAlign.Center,
|
||||
draw_emojis=True,
|
||||
)
|
||||
return img
|
||||
|
||||
|
||||
async def draw_pt(saying: str):
|
||||
return await asyncio.to_thread(_draw_pt, saying)
|
||||
Reference in New Issue
Block a user