def list_fonts():
    """
    Outputs the available fonts on stdout with a short description.
    """

    names = []
    for f in FigletFont.getFonts():
        names.append(f)
    names.sort()
    for name in names:
        print(name)
        desc = FigletFont.infoFont(name, short=True)
        if len(desc.strip()) == 0:
            desc = "-no description-"
        print("   ", desc)
예제 #2
0
    async def figletfonts(self, ctx: Context) -> None:
        """List all Figlet fonts."""
        await ctx.send("List of supported fonts:")
        out = FigletFont.getFonts()

        for page in pagify(', '.join(out), shorten_by=24):
            await ctx.send(box(page))
예제 #3
0
 async def figletrandom(self, ctx: Context, text: str):
     """Convert text to ascii art using random font."""
     font = random.choice(FigletFont.getFonts())
     f = Figlet(font=font)
     out = f.renderText(text)
     for page in pagify(out, shorten_by=24):
         await self.bot.say(box(page))
     await self.bot.say("Font: {}".format(font))
예제 #4
0
 def __post_init__(self):
     # Silently replace any unavailable theme properties with something
     # random instead of raising an exception
     if not self.font:
         self.font = self.get_random_font()
     if self.ascii_font not in FigletFont.getFonts():
         self.ascii_font = self.get_random_ascii_font()
     if not self.gradient or len(self.colors) == 0:
         self.gradient = self.get_random_gradient()
예제 #5
0
 def get_ascii_fonts(cls, max_height=15) -> List[str]:
     if hasattr(cls, "_ascii_fonts"):
         return cls._ascii_fonts
     fonts = FigletFont.getFonts()
     cls._ascii_fonts = [
         f for f in fonts
         if len(fmt("7Apps", font=f).split("\n")) <= max_height
     ]
     return cls._ascii_fonts
예제 #6
0
    async def figletrandom(self, ctx: Context, text: str) -> None:
        """Convert text to ascii art using random font."""
        font = random.choice(FigletFont.getFonts())

        f = Figlet(font=font)
        out = f.renderText(text)

        for page in pagify(out, shorten_by=24):
            await ctx.send(box(page))

        await ctx.send(f"Font: {font}")
def print_font_info(font, short=False):
    """
    Outputs information about the font on stdout.

    :param font: the name of the font to output the information for
    :type font: str
    :param short: whether to output short or long description
    :type short: bool
    """

    print(FigletFont.infoFont(font, short=short))
예제 #8
0
    async def figlet(self, ctx: Context, text: str, font=None):
        """Convert text to ascii art."""
        if font is None:
            font = 'slant'
        if font == 'random':
            fonts = FigletFont.getFonts()
            font = random.choice(fonts)

        f = Figlet(font=font)
        out = f.renderText(text)
        for page in pagify(out, shorten_by=24):
            await self.bot.say(box(page))
예제 #9
0
def figlet():
    """
    Render the search text using all possible figlet fonts.

    This loops through hundreds of fonts and may take a few seconds to return.
    """
    text = request.environ['SEARCH_TEXT']
    lines = []
    for font in sorted(FigletFont.getFonts()):
        lines.extend(gopher.formatter.figlet(text, font=font).splitlines())
        lines.append(font)
        lines.append('')
    return gopher.render_menu(*lines)
예제 #10
0
 async def figcmd(self, message):
     """.figlet <font> <text>"""
     args = utils.get_args(message)
     text = " ".join(args[1:])
     mode = args[0]
     if mode == "random":
         mode = random.choice(FigletFont.getFonts())
     try:
         fig = Figlet(font=mode, width=30)
     except FontNotFound:
         await message.edit("<code>Font not found</code>")
         return
     await message.edit("<code>\u206a" +
                        utils.escape_html(fig.renderText(text)) + "</code>")
 async def randascii(self, ctx, *, text: commands.clean_content):
     if len(text) > 30:
         return await ctx.send(
             f"**{ctx.author.name},** unfortunately to prevent spam, "
             f"the limit is **30** characters.\nSo you can only you use this part of the "
             f"sentence you tried: `{text[:30]}`")
     random_font = crack.insta_crack(stuff=True,
                                     things=FigletFont.getFonts())
     font = Figlet(font=random_font)
     out = font.renderText(text)
     for txt in render_text(out, shorten_by=30):
         async with ctx.channel.typing():
             await render_ascii(ctx,
                                text=txt,
                                font=random_font,
                                org_txt=text)
예제 #12
0
파일: General.py 프로젝트: semihaydin0/Evos
    async def ascii_random_command(self, ctx, *, text: str):
        try:
            fonts = FigletFont.getFonts()
            font = random.choice(fonts)

            f = Figlet(font=font)
            out = f.renderText(text)
            await ctx.send(f"```\n{out}\n```")

            logger.info(f"General | AsciiRandom | Tarafından: {ctx.author}")
        except Exception as e:
            asciiRandomEmbed = discord.Embed(title="Hata",
                                             description=f"{e}",
                                             colour=0xd92929)
            await ctx.send(embed=asciiRandomEmbed)

            logger.error(f"General | AsciiRandom | Error: {e}")
예제 #13
0
 async def figletcmd(self, message):
     """.figlet <font> <text>"""
     # We can't localise figlet due to a lack of fonts
     args = utils.get_args(message)
     if len(args) < 2:
         await utils.answer(message, self.strings["figlet_args"])
         return
     text = " ".join(args[1:])
     mode = args[0]
     if mode == "random":
         mode = random.choice(FigletFont.getFonts())
     try:
         fig = Figlet(font=mode, width=30)
     except FontNotFound:
         await utils.answer(message, self.strings["no_font"])
         return
     await message.edit("<code>\u206a" + utils.escape_html(fig.renderText(text)) + "</code>")
예제 #14
0
파일: weefig.py 프로젝트: wohali/weefig
def weefig_command_cb(data, buffer, args):
    font = "standard"
    color = ""
    text = ""
    args = args.split()

    i=0
    while i < len(args):
        if args[i] == "-f":
            font = args[i+1]
            i+=2
        elif args[i] == "-c":
            color = args[i+1]
            i+=2
        elif args[i] == "--fonts":
            weechat.prnt("","\n".join(FigletFont.getFonts()))
            break
        else:
            text = " ".join(args[i:])
            break
    text = set_text_font(text, font)
    print_color_text(text, color)
    return weechat.WEECHAT_RC_OK
예제 #15
0
 def get_random_ascii_font(self):
     fonts = FigletFont.getFonts()
     fitted = [f for f in fonts if len(fmt("7Apps", f).split("\n")) <= 15]
     return get_random(fitted)
예제 #16
0
 async def figletfonts(self, ctx: Context):
     """List all fonts."""
     await self.bot.say("List of supported fonts:")
     out = FigletFont.getFonts()
     for page in pagify(', '.join(out), shorten_by=24):
         await self.bot.say(box(page))
예제 #17
0
    async def ascii_fonts(self, ctx: commands.Context):
        all_fonts = FigletFont.getFonts()
        fonts = [f'`{font}`' for font in all_fonts]

        await ctx.paginate(', '.join(fonts))
예제 #18
0
def get_fonts() -> List[str]:
    return FigletFont.getFonts()
예제 #19
0
# que representa una clave en un diccionario de estilos de colores de texto
TIPOGRAFIAS = [('Bulbhead', 'ESTILO_STAR'), ('Block', 'ESTILO_SUNSET'),
               ('Drpepper', 'ESTILO_BOTANY'), ('Broadway', 'ESTILO_SKY'),
               ('Fender', 'ESTILO_SUNSET'), ('Banner3-D', 'ESTILO_STANDARD'),
               ('Alligator', 'ESTILO_MAGIC'), ('Starwars', 'ESTILO_STAR'),
               ('Cybermedium', 'ESTILO_STANDARD'),
               ('Contessa', 'ESTILO_BOTANY'), ('Shimrod', 'ESTILO_BOTANY'),
               ('Graffiti', 'ESTILO_MAGIC'), ('Gothic', 'ESTILO_BLOODY'),
               ('Big', 'ESTILO_MAGIC'), ('Crawford', 'ESTILO_SKY'),
               ('Doom', 'ESTILO_SUNSET'), ('Chunky', 'ESTILO_SUNSET'),
               ('Acrobatic', 'ESTILO_SKY'), ('Poison', 'ESTILO_BLOODY'),
               ('Univers', 'ESTILO_BOTANY')]

# Obtengo las tipografías ASCCI art disponibles en el sistema para luego testear
# si la puedo usar. Es una lista y paso todos los elementos a mayúsculas
TIPOGRAFIAS_DISPONIBLES = list(map(str.upper, FigletFont.getFonts()))

# Esto devuelve un comando para limpiar pantalla dependiendo de la plataforma
# Como al final este proyecto solo funciona para Windows se podría omitir
LIMPIAR = "clear" if sys.platform.startswith("linux") else "cls"

# --------------------------------- Métodos -----------------------------------


def pulse_tecla_para_continuar():
    ''' Detecta una pulsación cualquiera del teclado para continuar '''
    print(ESTILO_DESCRIPCION + " Pulse una tecla para continuar...")
    while True:
        if msvcrt.kbhit():
            key_stroke = msvcrt.getch()
            break
예제 #20
0
파일: main.py 프로젝트: ekin1106/text2art
import random
from pyfiglet import Figlet, FigletFont

import fire
from colorama import init

from text2art.color import colored
from text2art.utils import colorFormat

DEFAULT_FONT = "ghost"
font_list = FigletFont.getFonts()
# Key value pair reversal
color_dict = {value: key for key, value in colorFormat.COLORS.items()}


def lf():
    """Random display of 25 fonts"""
    return random.sample(font_list, 25)


def rd(text, on_color=None, attr=None, width=80, justify="center"):
    """An art font that generates random fonts 
       and random colors.
       
       
       Args:
        text: Get an character string.
        color: Get a color string,dye the input string 
               with the corresponding color.
        available text colors:
               red, green, yellow, blue, magenta, cyan, white.