Giter Site home page Giter Site logo

frostming / python-cfonts Goto Github PK

View Code? Open in Web Editor NEW
190.0 7.0 8.0 284 KB

Sexy fonts for the console

Home Page: https://python-cfonts.fming.dev

License: MIT License

Python 99.45% Makefile 0.55%
cli command-line-app terminal-colors click command-line-tools

python-cfonts's Introduction

  ██████╗ ███████╗  ██████╗  ███╗   ██╗ ████████╗ ███████╗
 ██╔════╝ ██╔════╝ ██╔═══██╗ ████╗  ██║ ╚══██╔══╝ ██╔════╝
 ██║      █████╗   ██║   ██║ ██╔██╗ ██║    ██║    ███████╗
 ██║      ██╔══╝   ██║   ██║ ██║╚██╗██║    ██║    ╚════██║
 ╚██████╗ ██║      ╚██████╔╝ ██║ ╚████║    ██║    ███████║
  ╚═════╝ ╚═╝       ╚═════╝  ╚═╝  ╚═══╝    ╚═╝    ╚══════╝

Tests

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

NOTE: This project supports Python 3.6+

Installation

$ pip install python-cfonts

Usage

Documentation

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]
              text

positional arguments:
  text

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
                        line
  -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.

Or generate the fonts pragramatically:

from cfonts import render, say

output = render('Hello world', colors=['red', 'yellow'], align='center')
print(output)

Supported Characters

A O 2 2 =
B P 3 3 @
C Q 4 4 #
D R 5 5 $
E S 6 6 %
F T 7 7 &
G U 8 8 (
H V 9 9 )
I W ! ! /
J X ? ? :
K Y . . ;
L Z + + ,
M 0 - - '
N 1 _ _ `` (space)
"

Contributing

python-cfonts is managed by pdm, first install it:

pipx install pdm

Then, install a dependencies:

pdm install -d

Run tests:

$ pdm run pytest tests

License

The project is originated by @dominikwilkowski, under GPLv2 license. Ported by @frostming, under MIT license. See LICENSE for details

Changelog

  • v1.5.2 Fix the RGB color codes for truecolor system.
  • v1.5.1
    • Fix the truecolor display on Windows.
    • Enable truecolor by default for Windows Terminal.
    • Add type hints for the codebase.
  • v1.5.0 Officially drop support of Python 2.7
  • v1.4.0 Officially drop support of Python 3.5
  • v1.3.1 Fix the sdist.
  • v1.3.0 Relicense to MIT.
  • v1.2.0 Add font tiny.
  • v1.1.0 Switch to argparse to drop dependency click.
  • v1.0.0 Support gradient colors and transition gradient.
  • v0.5.0 Add four new fonts and double quote as supported charater.
  • v0.3.1 Fix a bug that the background doesn't span the full width.
  • v0.3.0 Supports Python 2.7.
  • v0.2.0 Initial commit and testing.

python-cfonts's People

Contributors

ademord avatar dependabot-preview[bot] avatar dominikwilkowski avatar dtrodrigues avatar frostming avatar fun840 avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-cfonts's Issues

cannot install from source

When running pip3 install --no-binary :all: python-cfonts, the installed package name is "UNKOWN" and there's the following warning:
WARNING: Generating metadata for package python-cfonts produced metadata for project name unknown. Fix your #egg=python-cfonts fragments.

Installing from the wheel does work.

This is observed running Python 3.9 on macOS.

Full output:

$ pip3 install --user --no-cache-dir --no-binary :all: python-cfonts
Collecting python-cfonts
  Downloading python-cfonts-1.3.0.tar.gz (25 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
  WARNING: Generating metadata for package python-cfonts produced metadata for project name unknown. Fix your #egg=python-cfonts fragments.
Building wheels for collected packages: unknown, unknown
  Building wheel for unknown (PEP 517) ... done
  Created wheel for unknown: filename=UNKNOWN-0.0.0-py3-none-any.whl size=1776 sha256=1685105494e5aa954b6e5d6c60d3e8f15459e8a838e0990fa0cb2f5db95feae4
  Stored in directory: /private/var/folders/qj/c3wyldsj1295syv3dpxmd9x40000gn/T/pip-ephem-wheel-cache-627c71q1/wheels/91/b0/89/0e20f07b993f0a3ad336e3c2e942b5fa0f72288da4cfae73c1
  Building wheel for unknown (PEP 517) ... done
  Created wheel for unknown: filename=UNKNOWN-0.0.0-py3-none-any.whl size=1776 sha256=1685105494e5aa954b6e5d6c60d3e8f15459e8a838e0990fa0cb2f5db95feae4
  Stored in directory: /private/var/folders/qj/c3wyldsj1295syv3dpxmd9x40000gn/T/pip-ephem-wheel-cache-627c71q1/wheels/c6/d8/3c/9dbd2eac0de5b954c469e371fc437b0b0e569812cf9d5ba31b
Successfully built unknown unknown
Installing collected packages: unknown
Successfully installed unknown-0.0.0

Background colour doesn't span entire line

While kicking the tires, I noticed that my output differed from the tutorial:

image

I also tried outside of ipython from the CLI without any improvement.

  • Terminal editor: kitty
  • Shell: zsh
  • TERM=screen-256color

Please let me know if there's any other information you need.

Really nice package, thanks for sharing!

PS: Also tried konsole terminal emulator with the same result.

Gradients are dimmer than they should be

1.5.1 fixed the issue with gradients on windows, but there's still a problem: gradients are too dim.
This is what happens when I run the command cfonts "Hello World" -g red,blue on both the original cfonts and python-cfonts:
Here is the with the original:
image
And here's python-cfonts:
image
As you can see, python-cfonts is a lot dimmer. These screenshots were taken at the same time, in the same terminal. I don't really know if this is a bug or just the default value for brightness was set too low, but maybe add an option to change it, or at least set the default higher.

v0.2.0

  • Add tests
  • Better README

Full gradients don't work on Windows

I'm trying to get a full gradient (not just the ANSI colors) on Windows, but something is going wrong. I looked at the code to see how to enable full colors, and I saw that I can do that by setting the environment variable ENABLE_TRUECOLOR. When I try that though, it displays this:
image
I'm not really sure what's happening here, but I know this isn't what's supposed to be happening. I'm using Windows Terminal (with PowerShell if it matters), which I know supports full rgb color,
image
so there's some problem with the program. There are no errors when setting up pdm and stuff, so I'm not really sure what's going wrong here.

Edit: I realize it might not be obvious, but the reason there is red`,blue instead of just red,blue is because I'm using powershell, ` is the escape character, it will still act as a normal comma.

package fails to build from source due to absent [project]

See Homebrew/homebrew-core#76960

Reproduced below:

[root@30901eb6ee01 ~]# python3 -m pip install --no-binary :all: python-cfonts
Collecting python-cfonts
  Downloading python-cfonts-1.4.0.tar.gz (29 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpiqc2sda6
         cwd: /tmp/pip-install-92lm2rnb/python-cfonts_e4bf8c270cb047bf872b9218e577c9ff
    Complete output (18 lines):
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 280, in <module>
        main()
      File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 133, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/tmp/pip-build-env-oqmgzgsq/overlay/lib/python3.6/site-packages/pdm/pep517/api.py", line 34, in prepare_metadata_for_build_wheel
        dist_info = Path(metadata_directory, builder.dist_info_name)
      File "/tmp/pip-build-env-oqmgzgsq/overlay/lib/python3.6/site-packages/pdm/pep517/wheel.py", line 128, in dist_info_name
        name = to_filename(self.meta.project_name)
      File "/tmp/pip-build-env-oqmgzgsq/overlay/lib/python3.6/site-packages/pdm/pep517/base.py", line 143, in meta
        self._meta = Metadata(self.location / "pyproject.toml")
      File "/tmp/pip-build-env-oqmgzgsq/overlay/lib/python3.6/site-packages/pdm/pep517/metadata.py", line 85, in __init__
        self._read_pyproject()
      File "/tmp/pip-build-env-oqmgzgsq/overlay/lib/python3.6/site-packages/pdm/pep517/metadata.py", line 100, in _read_pyproject
        raise ProjectError("No [project] config in pyproject.toml")
    pdm.pep517.metadata.ProjectError: No [project] config in pyproject.toml
    ----------------------------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.