CFonts: Sexy fonts for the console _images/example.png

This is a Python port of @dominikwilkowski’s cfonts. Thanks for the original code and beautiful console fonts!

This project supports Python 3.6+


Recommended way: use pipx:

$ pipx install python-cfonts

Or alternatively, install using Pip:

$ pip install python-cfonts

Command Line Interface

usage: cfonts [-h] [-V]
              [-f {console,block,simpleBlock,simple,3d,simple3d,chrome,huge,grid,pallet,shade,slick}]
              [-c COLORS] [-b BACKGROUND] [-a {left,center,right}]
              [-l LETTER_SPACING] [-z LINE_HEIGHT] [-s] [-m MAX_LENGTH]
              [-g GRADIENT] [-i] [-t]

positional arguments:

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -f {console,block,simpleBlock,simple,3d,simple3d,chrome,huge,grid,pallet,shade,slick}, --font {console,block,simpleBlock,simple,3d,simple3d,chrome,huge,grid,pallet,shade,slick}
                        Use to define the font face
  -c COLORS, --colors COLORS
                        Use to define the font color
  -b BACKGROUND, --background BACKGROUND
                        Use to define the background color
  -a {left,center,right}, --align {left,center,right}
                        Use to align the text output
  -l LETTER_SPACING, --letter-spacing LETTER_SPACING
                        Use to define the letter spacing
  -z LINE_HEIGHT, --line-height LINE_HEIGHT
                        Use to define the line height
  -s, --spaceless       Use to define the background color
  -m MAX_LENGTH, --max-length MAX_LENGTH
                        Use to define the amount of maximum characters per
  -g GRADIENT, --gradient GRADIENT
                        Define gradient colors(separated by comma)
  -i, --independent-gradient
                        Set this option to re-calculate the gradient colors
                        for each new line.Only works in combination with the
                        gradient option.
  -t, --transition-gradient
                        Set this option to generate your own gradients. Each
                        color set in the gradient option will then be
                        transitioned to directly.



API References

cfonts.render(text: str, font: str = 'block', size: Tuple[int, int] = os.terminal_size(columns=80, lines=24), colors: Optional[List[str]] = None, background: str = 'transparent', align: str = 'left', letter_spacing: Optional[int] = None, line_height: int = 1, space: bool = True, max_length: int = 0, gradient: Optional[List[str]] = None, independent_gradient: bool = False, transition: bool = False, raw: bool = False)str

Main function to get the colored output for a string.

  • text – the string you want to render

  • font – use to define the font

  • size – a (width, height) tuple to define the window size

  • colors – a list of color names to render sequentially

  • background – background color name

  • align – the alignment method: left/center/right

  • letter_spacing – the amount of spacing inserted between letters

  • line_height – the height of each line

  • space – whether to wrap the output with blank lines

  • max_length – define the max length of per line, use 0 to disable

  • gradient – define the gradient color sequence

  • independent_gradient – whether to apply gradient to each line independently

  • transition – If set to True, will generate transition gradient colors


the colored output string

cfonts.say(text: str, **options)None

Render and write the output to stout.

  • text – the string you want to render

  • options – options passed as same as cfonts.render()