Files
Ultroid-fork/plugins/fontgen.py
Anonymous 4e65f218f5 Ultroid v0.0.8 | 17-6-21
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Danish <danish@ultroid.tech>
Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: divkix <divkix@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: Programming Error <error@notavailable.live>
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
2021-06-17 21:18:55 +05:30

48 lines
1.2 KiB
Python

"""
• `{i}font <font name> <text>`
Generate different fonts for the text.
• `{i}font`
To get list of fonts
"""
from . import _default, _double_stroke, _monospace, _small_caps
fonts = ["small caps ", "monospace ", "double stroke ", "script royal"]
@ultroid_cmd(
pattern="font ?(.*)",
)
async def _(e):
input = e.pattern_match.group(1)
if not input:
m = "**Available Fonts**\n\n"
for x in fonts:
m += f"• `{x}`\n"
return await eod(e, m)
try:
font = input.split(":", maxsplit=1)[0]
text = input.split(":", maxsplit=1)[1]
except BaseException:
return await eod(e, "`fonts small caps : Your Message`")
if font not in fonts:
return await eod(e, f"`{font} not in font list`.")
if font == "small caps ":
msg = gen_font(text, _small_caps)
if font == "monospace ":
msg = gen_font(text, _monospace)
if font == "double stroke ":
msg = gen_font(text, _double_stroke)
if font == "script royal ":
msg = gen_font(text, _script_royal)
await eor(e, msg)
def gen_font(text, new_font):
for q in text:
if q in _default:
new = new_font[_default.index(q)]
text = text.replace(q, new)
return text