npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cfonts

v3.3.0

Published

Sexy ANSI fonts for the console

Downloads

585,671

Readme

     ██████╗ ███████╗  ██████╗  ███╗   ██╗ ████████╗ ███████╗
    ██╔════╝ ██╔════╝ ██╔═══██╗ ████╗  ██║ ╚══██╔══╝ ██╔════╝
    ██║      █████╗   ██║   ██║ ██╔██╗ ██║    ██║    ███████╗
    ██║      ██╔══╝   ██║   ██║ ██║╚██╗██║    ██║    ╚════██║    ╔╗╔ ╔═╗ ╔╦╗ ╔═╗  ╦ ╔═╗
    ╚██████╗ ██║      ╚██████╔╝ ██║ ╚████║    ██║    ███████║    ║║║ ║ ║  ║║ ║╣   ║ ╚═╗
     ╚═════╝ ╚═╝       ╚═════╝  ╚═╝  ╚═══╝    ╚═╝    ╚══════╝    ╝╚╝ ╚═╝ ═╩╝ ╚═╝ ╚╝ ╚═╝

cfont styles

Installing

npm

npm i cfonts -g

yarn

yarn global add cfonts

To use it in your shell:

$ cfonts "Hello|World\!"

💡 Remember to escape the ! character with \ in the shell

Or use it in your project:

const cfonts = require('cfonts');

cfonts.say('Hello|world!', {
	font: 'block',              // define the font face
	align: 'left',              // define text alignment
	colors: ['system'],         // define all colors
	background: 'transparent',  // define the background color, you can also use `backgroundColor` here as key
	letterSpacing: 1,           // define letter spacing
	lineHeight: 1,              // define the line height
	space: true,                // define if the output text should have empty lines on top and on the bottom
	maxLength: '0',             // define how many character can be on one line
	gradient: false,            // define your two gradient colors
	independentGradient: false, // define if you want to recalculate the gradient for each new line
	transitionGradient: false,  // define if this is a transition between colors directly
	rawMode: false,             // define if the line breaks should be CRLF (`\r\n`) over the default LF (`\n`)
	env: 'node'                 // define the environment cfonts is being executed in
});

All settings are optional and shown here with their default

You can use cfonts in your project without the direct output to the console:

const cfonts = require('cfonts');

const prettyFont = cfonts.render('Hello|world!', {/* same settings object as above */});

prettyFont.string  // the ansi string for sexy console font
prettyFont.array   // returns the array for the output
prettyFont.lines   // returns the lines used
prettyFont.options // returns the options used

CLI Usage

Read more in the root repo.

Tests

This package is tested on the below platform and node combinations as part of our CI.

| Platform | Node | |----------|------| | Linux | v12 | | Linux | v14 | | Linux | v16 | | Linux | v18 | | Linux | v20 | | Linux | v22 | | MacOS | v16 | | MacOS | v18 | | MacOS | v20 | | MacOS | v22 | | Windows | v12 | | Windows | v14 | | Windows | v16 | | Windows | v18 | | Windows | v20 | | Windows | v22 |

Unit tests

The package comes with a bunch of unit tests that aim to cover 100% of the code base. For more details about the code coverage check out coveralls.

npm run test:unit

Type tests

Since the code base uses JSDocs we use typescript to test the inferred types from those comments. Typescript supports JSDocs and we use it in our test.

npm run test:types

Font file test

There is also a test suite for font files.

npm run test:fonts

This tool checks:

  • the existence of the font
  • all attributes of a font
  • each character for:
    • existence
    • consistent width
    • consistent lines

All tests

Run all tests via:

npm run test

Contributing

To build the repo install dependencies via:
(Since we ship a yarn.lock file please use yarn for development.)

yarn

and run the watch to continuously transpile the code.

yarn watch

Please look at the coding style and work with it, not against it ;)

Release History

  • 3.3.0 - Added raw-mode flag, bumped dependencies
  • 3.2.0 - Added TS type to the published npm package
  • 3.1.1 - Fixed #58 gradient color bug, added gray to gradient colors
  • 3.1.0 - Added support for -V flag fallback
  • 3.0.0 - Added rust library port, aligned APIs, added hex background colors, fixed minor alignment bugs, updated license from GPLv2 to GPLv3
  • 2.10.1 - bumped dependencies
  • 2.10.0 - bumped dependencies, added typescript definitions into npm bundle
  • 2.9.3 - bumped dependencies
  • 2.9.2 - bumped dependencies
  • 2.9.1 - bumped dependencies
  • 2.9.0 - added top and bottom align options
  • 2.8.6 - bumped dependencies
  • 2.8.5 - renamed branches
  • 2.8.4 - fixed block double quote
  • 2.8.3 - bumped dependencies
  • 2.8.2 - bumped dependencies, added linting, fixed #22 (again)
  • 2.8.1 - bumped dependencies
  • 2.8.0 - added environment support, added font tiny
  • 2.7.0 - added font slick, grid and pallet, added double quote to all fonts
  • 2.6.1 - fixed console maxLength, gradient and lineHeight, added more end-to-end tests
  • 2.6.0 - added transition gradients and sets
  • 2.5.2 - fixed jsDocs, added typescript type test
  • 2.5.1 - fixed array output to include everything including colors
  • 2.5.0 - added gradient option, separated code into files, added 100% unit testing coverage
  • 2.4.8 - removed ansi-styles from direct dependencies
  • 2.4.7 - fixed bug from adopting chalk v3 and hex colors
  • 2.4.6 - bumped dependencies, removed change-case dependency, added UpperCaseFirst with tests
  • 2.4.5 - bumped dependencies, moved to relative links for fonts for webpack support (#22)
  • 2.4.4 - bumped dependencies
  • 2.4.3 - bumped dependencies
  • 2.4.2 - bumped dependencies
  • 2.4.1 - updated to babel 7, removed runtime from dependencies
  • 2.4.0 - added font shade, added hex color support
  • 2.3.1 - added tests, fixed options, updated dependencies
  • 2.3.0 - added apostrophe support in all fonts
  • 2.2.3 - bumped dependencies
  • 2.2.2 - bumped dependencies
  • 2.2.1 - bumped dependencies
  • 2.2.0 - inside the API you can use line breaks as well as the pipe
  • 2.1.3 - refactored some loops
  • 2.1.2 - made WinSize more robust
  • 2.1.1 - fixed size detection in non-tty environments
  • 2.1.0 - rebuilt cfonts with pure functions, made colors case-insensitive
  • 2.0.1 - fixed terminal width detection
  • 2.0.0 - added tests, split into more pure functions
  • 1.2.0 - added transparent and system as default background and color option, added backgroundColor as alias for background, upgraded deps
  • 1.1.3 - fixed help text, removing old -t option
  • 1.1.2 - fixed issue with older commander version #3, updated docs
  • 1.1.1 - moved from babel-polyfill to babel-plugin-transform-runtime, added files to package.json, added images to docs, fixed dependencies
  • 1.1.0 - transpiled code to support node 0.12.15 and up
  • 1.0.2 - fixed background in console font, added comma, added font huge, added render method, added candy color
  • 1.0.1 - added chrome font, fonttest
  • 1.0.0 - refactor, added alignment and line height option, new cli commands, added simpleBlock
  • 0.0.13 - fixed simple3d
  • 0.0.12 - fixed simple3d and added to grunt test
  • 0.0.11 - added simple3d font
  • 0.0.10 - added npmignore, added to docs
  • 0.0.9 - added console font
  • 0.0.8 - fixed bugs, docs
  • 0.0.7 - changed to settings object
  • 0.0.6 - added 3d font
  • 0.0.5 - added grunt test
  • 0.0.4 - fixed simple font
  • 0.0.3 - fixes, added simple font
  • 0.0.2 - fixed paths
  • 0.0.1 - alpha test

License

Copyright (c) 2022 Dominik Wilkowski. Licensed under the GNU GPL-3.0-or-later.