diff --git a/AnimeFont/a-.jpg b/AnimeFont/a-.jpg new file mode 100644 index 0000000..78fca70 Binary files /dev/null and b/AnimeFont/a-.jpg differ diff --git a/AnimeFont/a.jpg b/AnimeFont/a.jpg new file mode 100644 index 0000000..58de927 Binary files /dev/null and b/AnimeFont/a.jpg differ diff --git a/AnimeFont/b-.webp b/AnimeFont/b-.webp new file mode 100644 index 0000000..1b4f56f Binary files /dev/null and b/AnimeFont/b-.webp differ diff --git a/AnimeFont/b.png b/AnimeFont/b.png new file mode 100644 index 0000000..48ef533 Binary files /dev/null and b/AnimeFont/b.png differ diff --git a/AnimeFont/c.png b/AnimeFont/c.png new file mode 100644 index 0000000..286453f Binary files /dev/null and b/AnimeFont/c.png differ diff --git a/AnimeFont/d.png b/AnimeFont/d.png new file mode 100644 index 0000000..1b12249 Binary files /dev/null and b/AnimeFont/d.png differ diff --git a/AnimeFont/e-.webp b/AnimeFont/e-.webp new file mode 100644 index 0000000..5af7660 Binary files /dev/null and b/AnimeFont/e-.webp differ diff --git a/AnimeFont/e.png b/AnimeFont/e.png new file mode 100644 index 0000000..5d23657 Binary files /dev/null and b/AnimeFont/e.png differ diff --git a/AnimeFont/f-.png b/AnimeFont/f-.png new file mode 100644 index 0000000..9752d6c Binary files /dev/null and b/AnimeFont/f-.png differ diff --git a/AnimeFont/f.png b/AnimeFont/f.png new file mode 100644 index 0000000..951a8a6 Binary files /dev/null and b/AnimeFont/f.png differ diff --git a/AnimeFont/g.png b/AnimeFont/g.png new file mode 100644 index 0000000..8f61f36 Binary files /dev/null and b/AnimeFont/g.png differ diff --git a/AnimeFont/h-.jpg b/AnimeFont/h-.jpg new file mode 100644 index 0000000..ff636f2 Binary files /dev/null and b/AnimeFont/h-.jpg differ diff --git a/AnimeFont/h.jpg b/AnimeFont/h.jpg new file mode 100644 index 0000000..453a28b Binary files /dev/null and b/AnimeFont/h.jpg differ diff --git a/AnimeFont/i-.jpg b/AnimeFont/i-.jpg new file mode 100644 index 0000000..36ee1da Binary files /dev/null and b/AnimeFont/i-.jpg differ diff --git a/AnimeFont/i.jpg b/AnimeFont/i.jpg new file mode 100644 index 0000000..8e42c28 Binary files /dev/null and b/AnimeFont/i.jpg differ diff --git a/AnimeFont/j.png b/AnimeFont/j.png new file mode 100644 index 0000000..747f292 Binary files /dev/null and b/AnimeFont/j.png differ diff --git a/AnimeFont/k-.png b/AnimeFont/k-.png new file mode 100644 index 0000000..40ffed6 Binary files /dev/null and b/AnimeFont/k-.png differ diff --git a/AnimeFont/k.png b/AnimeFont/k.png new file mode 100644 index 0000000..ff55048 Binary files /dev/null and b/AnimeFont/k.png differ diff --git a/AnimeFont/l.jpg b/AnimeFont/l.jpg new file mode 100644 index 0000000..1090b19 Binary files /dev/null and b/AnimeFont/l.jpg differ diff --git a/AnimeFont/m-.jpg b/AnimeFont/m-.jpg new file mode 100644 index 0000000..ed92fb0 Binary files /dev/null and b/AnimeFont/m-.jpg differ diff --git a/AnimeFont/m.jpg b/AnimeFont/m.jpg new file mode 100644 index 0000000..c21b8f1 Binary files /dev/null and b/AnimeFont/m.jpg differ diff --git a/AnimeFont/main.py b/AnimeFont/main.py new file mode 100644 index 0000000..4f602ca --- /dev/null +++ b/AnimeFont/main.py @@ -0,0 +1,104 @@ +import string +import pygame +import os + +pygame.init() # initiate pygame + +pygame.display.set_caption('Pygame') # set the window name + +letter_height = 80 +WINDOW_SIZE = (1, 0) # set up window size + +screen = pygame.display.set_mode(WINDOW_SIZE, 0, 32) # initiate screen + + +def filter_text(text): + t = list(map(lambda s: s.lower(), [s for s in text])) + + i_to_r = [] + for i, letter in enumerate(t): + if letter not in string.ascii_lowercase + " ": + i_to_r.append(i) + + load = 0 + for i in i_to_r: + del t[i - load] + load += 1 + + return "".join(t) + + +def get_letters(letter_height, path=None): + + letters = {letter.split(".")[0]: pygame.image.load(path + letter).convert() for letter in os.listdir(path) + if (letter.endswith(".png") or letter.endswith(".jpg")) and "-" not in letter} + + for key, letter in letters.items(): + s = letter.get_width() / letter.get_height() + letters[key] = pygame.transform.scale(letters[key], (int(letter_height * s), letter_height)) + + return letters + + +def get_word_length(word, letters): + return sum([letters[letter].get_width() for letter in word]) + + +def get_image(text, letters, letter_height, bg=(54, 57, 63)): + text = filter_text(text) + t = text.split(" ") + word_lengths = list(map(lambda x: get_word_length(x, letters), t)) + max_length = max(word_lengths) + if len(word_lengths) > 3: + max_length *= 2 + lines = 1 + cl = 0 + i = 0 + + # getting image size + for w, l in zip(t, word_lengths): + if cl + l > max_length: + cl = l + lines += 1 + else: + cl += l + + if i != len(t) - 1: + if cl + (letter_height * 0.5) > max_length: + cl = 0 + lines += 1 + else: + cl += (letter_height * 0.5) + + i += 1 + + # creating surface + sur = pygame.Surface((max_length, lines * letter_height)) + sur.fill(bg) + + # rendering text onto surface + pos = [0, 0] + i = 0 + for w, l in zip(t, word_lengths): + if pos[0] + l > max_length: + pos[0] = 0 + pos[1] += letter_height + for letter in w: + sur.blit(letters[letter], pos) + pos[0] += letters[letter].get_width() + + else: + for letter in w: + sur.blit(letters[letter], pos) + pos[0] += letters[letter].get_width() + + if i != len(t) - 1: + if pos[0] + (letter_height * 0.5) > max_length: + pos[0] = 0 + pos[1] += letter_height + else: + pos[0] += (letter_height * 0.5) + + i += 1 + + return sur diff --git a/AnimeFont/n.jpg b/AnimeFont/n.jpg new file mode 100644 index 0000000..c6a0824 Binary files /dev/null and b/AnimeFont/n.jpg differ diff --git a/AnimeFont/o-.jpg b/AnimeFont/o-.jpg new file mode 100644 index 0000000..c5451c5 Binary files /dev/null and b/AnimeFont/o-.jpg differ diff --git a/AnimeFont/o.jpg b/AnimeFont/o.jpg new file mode 100644 index 0000000..e0a58dc Binary files /dev/null and b/AnimeFont/o.jpg differ diff --git a/AnimeFont/p-.jpg b/AnimeFont/p-.jpg new file mode 100644 index 0000000..7ca05a6 Binary files /dev/null and b/AnimeFont/p-.jpg differ diff --git a/AnimeFont/p.jpg b/AnimeFont/p.jpg new file mode 100644 index 0000000..fe81902 Binary files /dev/null and b/AnimeFont/p.jpg differ diff --git a/AnimeFont/q-.jpg b/AnimeFont/q-.jpg new file mode 100644 index 0000000..b43755b Binary files /dev/null and b/AnimeFont/q-.jpg differ diff --git a/AnimeFont/q.jpg b/AnimeFont/q.jpg new file mode 100644 index 0000000..8058be2 Binary files /dev/null and b/AnimeFont/q.jpg differ diff --git a/AnimeFont/r-.jpg b/AnimeFont/r-.jpg new file mode 100644 index 0000000..b511d92 Binary files /dev/null and b/AnimeFont/r-.jpg differ diff --git a/AnimeFont/r.jpg b/AnimeFont/r.jpg new file mode 100644 index 0000000..033dbce Binary files /dev/null and b/AnimeFont/r.jpg differ diff --git a/AnimeFont/s-.jpg b/AnimeFont/s-.jpg new file mode 100644 index 0000000..183dd9a Binary files /dev/null and b/AnimeFont/s-.jpg differ diff --git a/AnimeFont/s.jpg b/AnimeFont/s.jpg new file mode 100644 index 0000000..531e8d3 Binary files /dev/null and b/AnimeFont/s.jpg differ diff --git a/AnimeFont/t-.jpg b/AnimeFont/t-.jpg new file mode 100644 index 0000000..3db52c5 Binary files /dev/null and b/AnimeFont/t-.jpg differ diff --git a/AnimeFont/t.jpg b/AnimeFont/t.jpg new file mode 100644 index 0000000..930ab2d Binary files /dev/null and b/AnimeFont/t.jpg differ diff --git a/AnimeFont/u.jpg b/AnimeFont/u.jpg new file mode 100644 index 0000000..a266808 Binary files /dev/null and b/AnimeFont/u.jpg differ diff --git a/AnimeFont/v-.jpg b/AnimeFont/v-.jpg new file mode 100644 index 0000000..18f3e3f Binary files /dev/null and b/AnimeFont/v-.jpg differ diff --git a/AnimeFont/v.jpg b/AnimeFont/v.jpg new file mode 100644 index 0000000..8b61b14 Binary files /dev/null and b/AnimeFont/v.jpg differ diff --git a/AnimeFont/w-.jpg b/AnimeFont/w-.jpg new file mode 100644 index 0000000..3aba202 Binary files /dev/null and b/AnimeFont/w-.jpg differ diff --git a/AnimeFont/w.jpg b/AnimeFont/w.jpg new file mode 100644 index 0000000..b25a014 Binary files /dev/null and b/AnimeFont/w.jpg differ diff --git a/AnimeFont/x-.jpg b/AnimeFont/x-.jpg new file mode 100644 index 0000000..8f83927 Binary files /dev/null and b/AnimeFont/x-.jpg differ diff --git a/AnimeFont/x-.png b/AnimeFont/x-.png new file mode 100644 index 0000000..9b66689 Binary files /dev/null and b/AnimeFont/x-.png differ diff --git a/AnimeFont/x.png b/AnimeFont/x.png new file mode 100644 index 0000000..f3a98cc Binary files /dev/null and b/AnimeFont/x.png differ diff --git a/AnimeFont/y.png b/AnimeFont/y.png new file mode 100644 index 0000000..38b99bd Binary files /dev/null and b/AnimeFont/y.png differ diff --git a/AnimeFont/z.png b/AnimeFont/z.png new file mode 100644 index 0000000..b13b4e0 Binary files /dev/null and b/AnimeFont/z.png differ diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..7c3f5d7 --- /dev/null +++ b/bot.py @@ -0,0 +1,42 @@ +import discord +import random +import json +import os +from discord.ext import commands + +intents = discord.Intents.all() + + +client = commands.Bot(command_prefix=lambda x, y: "HELLO", intents=intents) + + +@client.event +async def on_ready(): + print("KawaiiFont is ready.") + await client.change_presence(status=discord.Status.online, activity=discord.Game(".your text")) + + +@client.command() +@commands.has_permissions(administrator=True) +async def reload(ctx): + try: + for ext in os.listdir("extensions"): + if ext.endswith(".py"): + try: + client.unload_extension(f"extensions.{ext[:-3]}") + except: + pass + client.load_extension(f"extensions.{ext[:-3]}") + await ctx.send(f"Reloaded all extensions successfully.") + except Exception as e: + await ctx.send(e) + + +try: + for ext in os.listdir("extensions"): + if ext.endswith(".py"): + client.load_extension(f"extensions.{ext[:-3]}") +except Exception as e: + print(e) + +client.run("") # id here diff --git a/extensions/__pycache__/functions.cpython-39.pyc b/extensions/__pycache__/functions.cpython-39.pyc new file mode 100644 index 0000000..ee6b863 Binary files /dev/null and b/extensions/__pycache__/functions.cpython-39.pyc differ diff --git a/extensions/functions.py b/extensions/functions.py new file mode 100644 index 0000000..dc63281 --- /dev/null +++ b/extensions/functions.py @@ -0,0 +1,27 @@ +import discord +from discord.ext import commands +from KawaiiFont.AnimeFont.main import * + + +class Functions(commands.Cog): + + def __init__(self, client): + self.client = client + self.letter_height = 300 + self.letters = get_letters(self.letter_height, "AnimeFont/") + + @commands.Cog.listener() + async def on_message(self, message): + if message.author == self.client.user: + return + if str(message.content)[0] == ".": + await message.channel.purge(limit=1) + img = get_image(str(message.content)[1:], self.letters, self.letter_height) + pygame.image.save(img, f"AnimeFont/KawaiiFolder/KawaiiFont - {str(message.content)}.png") + with open(f"AnimeFont/KawaiiFolder/KawaiiFont - {str(message.content)}.png", "rb") as f: + picture = discord.File(f) + await message.channel.send(file=picture) + + +def setup(client): + client.add_cog(Functions(client)) \ No newline at end of file