Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cfonts

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cfonts - npm Package Compare versions

Comparing version 0.0.13 to 1.0.0

fonts/simpleBlock.json

118

bin/font.js
#!/usr/bin/env node
/*
/***************************************************************************************************************************************************************
*
* cfonts
* https://github.com/dominikwilkowski/cfonts
*
* Copyright (c) 2015 Dominik Wilkowski
* Licensed under the MIT license.
*/
* Sexy fonts for the console. (CLI output)
*
* @license https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE GNU GPLv2
* @author Dominik Wilkowski hi@dominik-wilkowski.com
* @repository https://github.com/dominikwilkowski/cfonts
*
**************************************************************************************************************************************************************/

@@ -16,53 +20,85 @@ 'use strict';

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
var fs = require('fs');
var chalk = require('chalk');
var program = require('commander');
var CFONTS = require('./../index.js');
const Fs = require('fs');
const Chalk = require('chalk');
const Program = require('commander');
const CFonts = require('./../index.js');
var $package = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8'));
var $version = $package.version;
const Package = JSON.parse(Fs.readFileSync(__dirname + '/../package.json', 'utf8'));
const Version = Package.version;
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Custom functions
// Setting up command line tool
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
function list(val) {
return val.split(',');
}
Program
.description(`This is a tool for sexy fonts in the console. Give your cli some love.`)
.version(`v${Version}`)
.usage(`"<value>" [option1] <input1> [option2] <input1>,<input2> [option3]`)
.option(`-f, --font <keyword>`, `define "font face"`, `block`)
.option(`-a, --align <keyword>`, `define "alignment" for the text`, `left`)
.option(`-c, --colors <keyword>,<keyword>...`, `provide colors for text`, `white`)
.option(`-b, --background <keyword>`, `provide background color`, `Black`)
.option(`-l, --letter-spacing <n>`, `define letter spacing {integer}`)
.option(`-z, --line-height <n>`, `define line height {integer}`, 1)
.option(`-s, --spaceless`, `surpress space on top and on the bottom`)
.option(`-m, --max-length <keyword>`, `define how many character can be on one line`)
.action(function( text ) {
Program.text = text; //add flagless option for text
})
.on('--help', function() { //adding options for each keyword section
console.log( Chalk.bold(` Font face options:`) );
console.log(` [ ${CFonts.FONTFACES.join(', ')} ]\n`);
console.log( Chalk.bold(` Alignment options:`) );
console.log(` [ ${CFonts.ALIGNMENT.join(', ')} ]\n`);
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Command line
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
program
.version( $version )
.usage('[option1] <input1> [options2] <input1>,<input2>')
.option('-t, --text <textinput>', '"textinput" to be converted into a nice font')
.option('-f, --font <fontname>', '"fontname" to be used')
.option('-c, --colors <color>,<color>...', 'provide colors in format: red,blue etc.', list)
.option('-b, --background <background>', 'provide background color in format: \'white\'')
.option('-l, --letter-spacing <letterSpacing>', 'letterSpacing to be used as integer')
.option('-s, --space <space>', 'define if the output text should have empty lines on top and on the bottom')
.option('-m, --max-length <maxLength', 'define how many character can be on one line')
.parse(process.argv);
console.log( Chalk.bold(` Color options:`) );
console.log(` [ ${CFonts.COLORS.join(', ')} ]\n`);
console.log( Chalk.bold(` background color options:`) );
console.log(` [ ${CFonts.BGCOLORS.join(', ')} ]\n`);
})
.parse( process.argv );
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Programm
// Execute programm
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
if(program.text !== undefined) {
if(Program.text !== undefined) {
//log OPTIONS for debugging
if( CFonts.DEBUG ) {
CFonts.debugging.report(
`OPTIONS:\n` +
` CFonts.say("${Program.text}", {\n` +
` 'font': "${Program.font}",\n` +
` 'align': "${Program.align}",\n` +
` 'colors': ${Program.colors ? JSON.stringify( Program.colors.split(',') ) : []},\n` +
` 'background': "${Program.background}",\n` +
` 'letterSpacing': ${Program.letterSpacing},\n` +
` 'lineHeight': ${Program.lineHeight},\n` +
` 'space': ${Program.spaceless ? false : true},\n` +
` 'maxLength': ${Program.maxLength}\n` +
` });`,
3
);
}
var cfonts = new CFONTS({
'text': program.text,
'font': program.font,
'colors': program.colors,
'background': program.background,
'letterSpacing': program.letterSpacing,
'space': program.space,
'maxLength': program.maxLength
//execute cfonts
CFonts.say(Program.text, {
'font': Program.font,
'align': Program.align,
'colors': Program.colors ? Program.colors.split(',') : [],
'background': Program.background,
'letterSpacing': Program.letterSpacing,
'lineHeight': Program.lineHeight,
'space': Program.spaceless ? false : true,
'maxLength': Program.maxLength
});
}
else {
console.log("\n" + ' Please provide a text to convert with ' + chalk.styles.green.open + 'fonts -t "Text"' + chalk.styles.green.close + "\n");
else { //we do need text to convert
CFonts.log.error(
`Please provide text to convert with ${Chalk.green(`cfonts -t "Text"`)}\n` +
`Run ${Chalk.green(`cfonts --help`)} for more infos`
);
}
{
"name": "3D",
"version": "0.0.1",
"homepage": "https://github.com/dominikwilkowski/grunt-font",
"homepage": "https://github.com/dominikwilkowski/cfonts",
"colors": 2,

@@ -6,0 +6,0 @@ "lines": 9,

{
"name": "block",
"version": "0.0.3",
"homepage": "https://github.com/dominikwilkowski/grunt-font",
"homepage": "https://github.com/dominikwilkowski/cfonts",
"colors": 2,

@@ -6,0 +6,0 @@ "lines": 6,

{
"name": "simple",
"version": "0.0.2",
"homepage": "https://github.com/dominikwilkowski/grunt-font",
"homepage": "https://github.com/dominikwilkowski/cfonts",
"colors": 1,

@@ -6,0 +6,0 @@ "lines": 4,

{
"name": "simple3d",
"version": "0.0.1",
"homepage": "https://github.com/dominikwilkowski/grunt-font",
"homepage": "https://github.com/dominikwilkowski/cfonts",
"colors": 1,

@@ -27,151 +27,151 @@ "lines": 7,

"A": [
"",
" __",
" /'__`\\",
"/\\ \\_\\.\\_",
" ",
" __ ",
" /'__`\\ ",
"/\\ \\_\\.\\_ ",
"\\ \\__/.\\_\\",
" \\/__/\\/_/",
""
" "
],
"B": [
" __",
"/\\ \\",
"\\ \\ \\____",
" __ ",
"/\\ \\ ",
"\\ \\ \\____ ",
" \\ \\ ,. \\",
" \\ \\____/",
" \\/___/",
""
" \\/___/ ",
" "
],
"C": [
"",
" ___",
" /'___\\",
"/\\ \\__/",
" ",
" ___ ",
" /'___\\ ",
"/\\ \\__/ ",
"\\ \\____\\",
" \\/____/",
""
" "
],
"D": [
" __",
" /\\ \\",
" \\_\\ \\",
"/\\ ,. \\",
" __ ",
" /\\ \\ ",
" \\_\\ \\ ",
"/\\ ,. \\ ",
"\\ \\____\\",
" \\/___ /",
""
" "
],
"E": [
"",
" __",
" / ,.`\\",
"/\\ __/",
" ",
" __ ",
" / ,.`\\ ",
"/\\ __/ ",
"\\ \\____\\",
" \\/____/",
""
" "
],
"F": [
" ___",
" /'___\\",
"/\\ \\__/",
" ___ ",
" /'___\\ ",
"/\\ \\__/ ",
"\\ \\ ,__\\",
" \\ \\_\\_/",
" \\/_/",
""
" \\/_/ ",
" "
],
"G": [
" __",
" / _ `\\",
"/\\ \\_\\ \\",
"\\ \\____ \\",
" __ ",
" / _ `\\ ",
"/\\ \\_\\ \\ ",
"\\ \\____ \\ ",
" \\/___/\\ \\",
" /\\____/",
" \\_/__/"
" \\_/__/ "
],
"H": [
" __",
"/\\ \\",
"\\ \\ \\___",
" \\ \\ _ `\\",
" __ ",
"/\\ \\ ",
"\\ \\ \\___ ",
" \\ \\ _ `\\ ",
" \\ \\_\\ \\_\\",
" \\/_/\\/_/",
""
" "
],
"I": [
"",
" __",
"/\\_\\",
"\\/\\ \\",
" ",
" __ ",
"/\\_\\ ",
"\\/\\ \\ ",
" \\ \\ \\",
" \\/_/",
""
" "
],
"J": [
" __",
" /\\_\\",
" \\/\\ \\",
" _\\ \\ \\",
" __ ",
" /\\_\\ ",
" \\/\\ \\ ",
" _\\ \\ \\ ",
"/\\ \\_\\ \\",
"\\ \\____/",
" \\/___/"
" \\/___/ "
],
"K": [
" __ __",
" /\\ \\/ \\",
" \\ \\ <",
" \\ \\ ^ \\",
" __ __ ",
" /\\ \\/ \\ ",
" \\ \\ < ",
" \\ \\ ^ \\ ",
" \\ \\_\\ \\_\\",
" \\/_/\\/_/",
""
" "
],
"L": [
" ___",
"/\\_ \\",
"\\//\\ \\",
" \\_\\ \\_",
" ___ ",
"/\\_ \\ ",
"\\//\\ \\ ",
" \\_\\ \\_ ",
" /\\____\\",
" \\/____/",
""
" "
],
"M": [
"",
" ___ ___",
"/' __` __`\\",
"/\\ \\/\\ \\/\\ \\",
" ",
" ___ ___ ",
"/' __` __`\\ ",
"/\\ \\/\\ \\/\\ \\ ",
"\\ \\_\\ \\_\\ \\_\\",
" \\/_/\\/_/\\/_/",
""
" "
],
"N": [
"",
" ___",
"/' _ `\\",
"/\\ \\/\\ \\",
" ",
" ___ ",
"/' _ `\\ ",
"/\\ \\/\\ \\ ",
"\\ \\_\\ \\_\\",
" \\/_/\\/_/",
""
" "
],
"O": [
"",
" ___",
" / __`\\",
" ",
" ___ ",
" / __`\\ ",
"/\\ \\_\\ \\",
"\\ \\____/",
" \\/___/",
""
" \\/___/ ",
" "
],
"P": [
"",
" _____",
"/\\ '__`\\",
" ",
" _____ ",
"/\\ '__`\\ ",
"\\ \\ \\_\\ \\",
" \\ \\ ,__/",
" \\ \\ \\/",
" \\/_/"
" \\ \\ \\/ ",
" \\/_/ "
],
"Q": [
"",
" __",
" /'__`\\",
"/\\ \\L\\ \\",
"\\ \\___, \\",
" ",
" __ ",
" /'__`\\ ",
"/\\ \\L\\ \\ ",
"\\ \\___, \\ ",
" \\/___/\\_\\",

@@ -181,25 +181,25 @@ " \\/_/"

"R": [
"",
" _ __",
" ",
" _ __ ",
"/\\` __\\",
"\\ \\ \\/",
" \\ \\_\\",
" \\/_/",
""
"\\ \\ \\/ ",
" \\ \\_\\ ",
" \\/_/ ",
" "
],
"S": [
"",
" ____",
" / ,__\\",
" ",
" ____ ",
" / ,__\\ ",
"/\\__, `\\",
"\\/\\____/",
" \\/___/",
""
" \\/___/ ",
" "
],
"T": [
" __",
"/\\ \\__",
"\\ \\ ,_\\",
" \\ \\ \\/",
" \\ \\ \\_",
" __ ",
"/\\ \\__ ",
"\\ \\ ,_\\ ",
" \\ \\ \\/ ",
" \\ \\ \\_ ",
" \\ \\__\\",

@@ -209,70 +209,70 @@ " \\/__/"

"U": [
"",
" __ __",
"/\\ \\/\\ \\",
" ",
" __ __ ",
"/\\ \\/\\ \\ ",
"\\ \\ \\_\\ \\",
" \\ \\____/",
" \\/___/",
""
" \\/___/ ",
" "
],
"V": [
"",
" __ __",
" ",
" __ __ ",
"/\\ \\/\\ \\",
"\\ \\ \\/ |",
" \\ \\___/",
" \\/__/",
""
" \\/__/ ",
" "
],
"W": [
"",
" __ __ __",
"/\\ \\/\\ \\/\\ \\",
" ",
" __ __ __ ",
"/\\ \\/\\ \\/\\ \\ ",
"\\ \\ \\_/ \\_/ \\",
" \\ \\___^___/'",
" \\/__//__/",
""
" \\/__//__/ ",
" "
],
"X": [
"",
" __ _",
"/\\ \\/'\\",
"\\/> </",
" ",
" __ _ ",
"/\\ \\/'\\ ",
"\\/> </ ",
" /\\_/\\_\\",
" \\//\\/_/",
""
" "
],
"Y": [
"",
" __ __",
" /\\ \\_\\ \\",
" \\/`____ \\",
" ",
" __ __ ",
" /\\ \\_\\ \\ ",
" \\/`____ \\ ",
" `/___/> \\",
" /\\___/",
" \\/__/"
" \\/__/ "
],
"Z": [
"",
" ____",
"/\\_ ,`\\",
"\\/_/ /_",
" ",
" ____ ",
"/\\_ ,`\\ ",
"\\/_/ /_ ",
" /\\____\\",
" \\/____/",
""
" "
],
"0": [
" __",
" /'__`\\",
"/\\ \\/\\ \\",
"\\ \\ \\ \\ \\",
" __ ",
" /'__`\\ ",
"/\\ \\/\\ \\ ",
"\\ \\ \\ \\ \\ ",
" \\ \\ \\_\\ \\",
" \\ \\____/",
" \\/___/"
" \\/___/ "
],
"1": [
" _",
" /' \\",
"/\\_, \\",
"\\/_/\\ \\",
" \\ \\ \\",
" _ ",
" /' \\ ",
"/\\_, \\ ",
"\\/_/\\ \\ ",
" \\ \\ \\ ",
" \\ \\_\\",

@@ -282,70 +282,70 @@ " \\/_/"

"2": [
" ___",
" /'___`\\",
"/\\_\\ /\\ \\",
"\\/_/// /__",
" ___ ",
" /'___`\\ ",
"/\\_\\ /\\ \\ ",
"\\/_/// /__ ",
" // /_\\ \\",
" /\\______/",
" \\/_____/"
" \\/_____/ "
],
"3": [
" __",
" /'__`\\",
"/\\_\\L\\ \\",
"\\/_/_\\_<_",
" __ ",
" /'__`\\ ",
"/\\_\\L\\ \\ ",
"\\/_/_\\_<_ ",
" /\\ \\L\\ \\",
" \\ \\____/",
" \\/___/"
" \\/___/ "
],
"4": [
" __ __",
"/\\ \\\\ \\",
"\\ \\ \\\\ \\",
" \\ \\ \\\\ \\_",
" __ __ ",
"/\\ \\\\ \\ ",
"\\ \\ \\\\ \\ ",
" \\ \\ \\\\ \\_ ",
" \\ \\__ ,__\\",
" \\/_/\\_\\_/",
" \\/_/"
" \\/_/ "
],
"5": [
" ______",
"/\\ ___\\",
"\\ \\ \\__/",
" \\ \\___``\\",
" ______ ",
"/\\ ___\\ ",
"\\ \\ \\__/ ",
" \\ \\___``\\ ",
" \\/\\ \\L\\ \\",
" \\ \\____/",
" \\/___/"
" \\/___/ "
],
"6": [
" ____",
" /'___\\",
"/\\ \\__/",
"\\ \\ _``\\",
" ____ ",
" /'___\\ ",
"/\\ \\__/ ",
"\\ \\ _``\\ ",
" \\ \\ \\L\\ \\",
" \\ \\____/",
" \\/___/"
" \\/___/ "
],
"7": [
" ________",
" ________ ",
"/\\____ \\",
"\\/___/' /'",
" /' /'",
" /' /'",
" /\\_/",
" \\//"
" /' /' ",
" /' /' ",
" /\\_/ ",
" \\// "
],
"8": [
" __",
" /' _`\\",
"/\\ \\L\\ \\",
"\\/_> _ <_",
" __ ",
" /' _`\\ ",
"/\\ \\L\\ \\ ",
"\\/_> _ <_ ",
" /\\ \\L\\ \\",
" \\ \\____/",
" \\/___/"
" \\/___/ "
],
"9": [
" __",
" /'_ `\\",
"/\\ \\L\\ \\",
"\\ \\___, \\",
" \\/__,/\\ \\",
" __ ",
" /'_ `\\ ",
"/\\ \\L\\ \\ ",
"\\ \\___, \\ ",
" \\/__,/\\ \\ ",
" \\ \\_\\",

@@ -355,7 +355,7 @@ " \\/_/"

"!": [
" __",
"/\\ \\",
"\\ \\ \\",
" \\ \\ \\",
" \\ \\_\\",
" __ ",
"/\\ \\ ",
"\\ \\ \\ ",
" \\ \\ \\ ",
" \\ \\_\\ ",
" \\/\\_\\",

@@ -365,7 +365,7 @@ " \\/_/"

"?": [
" _",
" /'_`\\",
" _ ",
" /'_`\\ ",
"/\\_\\/\\`\\",
"\\/_//'/'",
" /\\_\\",
" /\\_\\ ",
" \\/\\_\\",

@@ -375,7 +375,7 @@ " \\/_/"

".": [
"",
"",
"",
"",
" __",
" ",
" ",
" ",
" ",
" __ ",
"/\\_\\",

@@ -385,25 +385,25 @@ "\\/_/"

"+": [
" __",
" /\\ \\",
" \\_\\ \\___",
" __ ",
" /\\ \\ ",
" \\_\\ \\___ ",
"/\\___ __\\",
"\\/__/\\ \\_/",
" \\ \\_\\",
" \\/_/"
" \\ \\_\\ ",
" \\/_/ "
],
"-": [
"",
"",
" _______",
" ",
" ",
" _______ ",
"/\\______\\",
"\\/______/",
"",
""
" ",
" "
],
"_": [
"",
"",
"",
"",
" _______",
" ",
" ",
" ",
" ",
" _______ ",
" /\\______\\",

@@ -413,15 +413,15 @@ " \\/______/"

"=": [
"",
" _______",
"/\\______\\",
"\\/______/_",
" ",
" _______ ",
"/\\______\\ ",
"\\/______/_ ",
" /\\______\\",
" \\/______/",
""
" "
],
"@": [
" __",
" /'_`\\_",
" /'/'_` \\",
"/\\ \\ \\L\\ \\",
" __ ",
" /'_`\\_ ",
" /'/'_` \\ ",
"/\\ \\ \\L\\ \\ ",
"\\ \\ `\\__,_\\",

@@ -432,14 +432,14 @@ " \\ `\\_____\\",

"#": [
" __ __",
" _\\ \\\\ \\__",
"/\\__ _ _\\",
"\\/_L\\ \\\\ \\L_",
" __ __ ",
" _\\ \\\\ \\__ ",
"/\\__ _ _\\ ",
"\\/_L\\ \\\\ \\L_ ",
" /\\_ _ _\\",
" \\/_/\\_\\\\_\\/",
" \\/_//_/"
" \\/_//_/ "
],
"$": [
" _",
" /|_\\_",
" /' _ `\\",
" _ ",
" /|_\\_ ",
" /' _ `\\ ",
" \\ \\___ \\",

@@ -451,7 +451,7 @@ " \\ `\\_ _/",

"%": [
" __ __",
"/\\_\\ /\\_\\",
"\\/_/ / / /",
" / / /",
" / / / __",
" __ __ ",
"/\\_\\ /\\_\\ ",
"\\/_/ / / / ",
" / / / ",
" / / / __ ",
" / / / /\\_\\",

@@ -461,6 +461,6 @@ " \\/_/ \\/_/"

"&": [
" ____",
" /| _ \\",
" |/\\ ` |",
" \\ / __`\\/\\",
" ____ ",
" /| _ \\ ",
" |/\\ ` | ",
" \\ / __`\\/\\ ",
" /| \\L> <_",

@@ -471,45 +471,45 @@ " | \\_____/\\/",

"(": [
" _",
" /' \\",
"/\\ ,/",
"\\ \\ \\",
" \\ \\ `\\",
" _ ",
" /' \\ ",
"/\\ ,/ ",
"\\ \\ \\ ",
" \\ \\ `\\ ",
" \\ `\\__\\",
" `\\/_/"
" `\\/_/ "
],
")": [
" __",
"/\\ `\\",
"\\`\\ \\",
" `\\`\\ \\",
" __ ",
"/\\ `\\ ",
"\\`\\ \\ ",
" `\\`\\ \\ ",
" `\\/' \\",
" /\\__/",
" \\/_/"
" \\/_/ "
],
"/": [
" __",
" __ ",
" /\\_\\",
" / / /",
" / / /",
" / / /",
"/ / /",
"\\/_/"
" / / / ",
" / / / ",
"/ / / ",
"\\/_/ "
],
":": [
"",
" __",
"/\\_\\",
"\\/_/_",
" ",
" __ ",
"/\\_\\ ",
"\\/_/_ ",
" /\\_\\",
" \\/_/",
""
" "
],
";": [
"",
" __",
"/\\_\\",
"\\/_/_",
" ",
" __ ",
"/\\_\\ ",
"\\/_/_ ",
" /\\ \\",
" \\ \\/",
" \\/"
" \\/ "
],

@@ -516,0 +516,0 @@ " ": [

@@ -40,18 +40,23 @@ /*

exec: {
test01: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü"',
test02: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -c red,magenta -m 15',
test01: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü"',
test02: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -c red,magenta -m 15',
test03: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "simple"',
test04: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "simple" -c yellow -m 20',
test03: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "simple"',
test04: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "simple" -c yellow -m 20',
test05: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "3d"',
test06: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "3d" -c magenta,yellow -m 7',
test05: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "3d"',
test06: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "3d" -c magenta,yellow -m 7',
test07: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "console"',
test08: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "console" -c blue -b white',
test07: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "console"',
test08: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "console" -c blue -b white',
test09: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "simple3d"',
test10: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "simple3d" -c cyan -b white',
test09: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "simple3d"',
test10: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "simple3d" -c cyan -b white',
test11: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "simpleBlock"',
test12: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -f "simpleBlock" -c green -b white',
test13: 'cfonts "a b c defghijklmnopqrstuvwxyz0123456789\!?.+-_=@#$%&()/:;ü" -a "center"',
test13: 'cfonts "a b c" -a right',
},
});

@@ -58,0 +63,0 @@

@@ -1,173 +0,607 @@

/*
/***************************************************************************************************************************************************************
*
* cfonts
* https://github.com/dominikwilkowski/cfonts
*
* Copyright (c) 2015 Dominik Wilkowski
* Licensed under the MIT license.
*/
* Sexy fonts for the console. (CLI output)
*
* @license https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE GNU GPLv2
* @author Dominik Wilkowski hi@dominik-wilkowski.com
* @repository https://github.com/dominikwilkowski/cfonts
*
**************************************************************************************************************************************************************/
// 'use strict';
'use strict';
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Dependencies
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
var fs = require('fs');
var chalk = require('chalk');
var changeCase = require('change-case');
const ChangeCase = require('change-case');
const WinSize = require('window-size');
const Chalk = require(`chalk`);
const Fs = require(`fs`);
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Custom functions
// Constructor
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
function colorize($font, OPTIONS, $character) {
const CFonts = (() => { //constructor factory
if($font.colors > 1) {
for(var o = 0, ll = $font.colors; o < ll; o++) { //convert colors
var open = new RegExp('<c' + (o + 1) + '>', 'g');
var close = new RegExp('</c' + (o + 1) + '>', 'g');
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private function
// GetFont, Get and set a selected JSON font-file object into global namespace
//
// @param font {string} The name of the font to be returned
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
const GetFont = ( font ) => {
CFonts.debugging.report(`Running GetFont`, 1);
var color = OPTIONS.colors[o] || "white";
//check selected font exists in preset
if( CFonts.FONTFACES.indexOf( font ) === -1 ) {
CFonts.log.error(`Please use a font from the supported stack:\n${Chalk.green(`[ ${CFonts.FONTFACES.join(' | ')} ]`)}`);
$character = $character.replace(open, chalk.styles[color.toLowerCase()].open);
$character = $character.replace(close, chalk.styles[color.toLowerCase()].close);
process.exit(1); //exit program with failure code
}
}
return $character;
//try loading the font file
try {
let fontFile = __dirname + '/fonts/' + font + '.json'; //build font path
let FONTFACE = JSON.parse( Fs.readFileSync(fontFile, 'utf8') ); //read font file
}
CFonts.debugging.report(`GetFont: Fontface path selected: "${fontFile}"`, 2);
CFonts.FONTFACE = FONTFACE;
}
catch( error ) {
CFonts.debugging.error(`Font file for "${font}" errored out: ${error}`, 2);
function equalWidth($character) {
var charWidth = 0;
CFonts.log.error(`Font file for "${font}" failed to connect to us.\nTry reinstalling this package.`);
for(var w = $character.length - 1; w >= 0; w--) {
$char = $character[w].replace(/(<([^>]+)>)/ig, '');
process.exit(1); //exit program with failure code
}
};
if( $char.length > charWidth ) {
charWidth = $char.length;
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private function
// CharLength, return the max width of a character by looking at its longest line
//
// @param character {array} The character array from the font face object
//
// @return {integer} The length of a longest line in a charater
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
const CharLength = ( character ) => {
CFonts.debugging.report(`Running CharLength`, 1);
let charWidth = 0;
for(let i = 0; i < CFonts.FONTFACE.lines; i++) {
let char = character[ i ].replace(/(<([^>]+)>)/ig, ''); //get character and strip color infos
if( char.length > charWidth ) {
charWidth = char.length; //assign only largest
}
};
if( charWidth === 0 && CFonts.OPTIONS.letterSpacing > 0 ) {
CFonts.debugging.report(`CharLength: Adding space to letter spacing`, 1);
charWidth = 1;
}
return charWidth;
};
return charWidth;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private function
// AddLine, Add a new line to the output array
//
// @param output {array} The output array the line shall be appended to
//
// @return {array} The output array with new line
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
const AddLine = ( output ) => {
CFonts.debugging.report(`Running AddLine`, 1);
let lineHeight = CFonts.OPTIONS.lineHeight;
if( output.length === 0 ) {
lineHeight = 0;
}
let lines = CFonts.FONTFACE.lines + output.length + lineHeight;
let length = output.length;
for(let i = length; i < lines; i++) {
let index = i - length;
if( index > lineHeight ) {
output[ i ] = CFonts.FONTFACE.buffer[ ( index - lineHeight ) ];
}
else {
output[ i ] = '';
}
}
return output;
};
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Main logic
// Private function
// AddChar, Add a new character to the output array
//
// @param CHAR {string} The character to be added
// @param output {array} The output array the line shall be appended to
//
// @return {array} The output array with new line
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
function cfonts($SETTINGS) {
const AddChar = ( CHAR, output ) => {
CFonts.debugging.report(`Running AddChar with "${CHAR}"`, 1);
//options
var OPTIONS = {
font: $SETTINGS.font || 'block', //define the font face
colors: $SETTINGS.colors || [], //define all colors
background: $SETTINGS.background || 'Black', //define the background color
letterSpacing: $SETTINGS.letterSpacing === undefined ? 1 : $SETTINGS.letterSpacing, //define letter spacing
space: $SETTINGS.space === undefined ? true : $SETTINGS.space, //define if the output text should have empty lines on top and on the bottom
maxLength: $SETTINGS.maxLength || 10 //define how many character can be on one line
let lines = output.length - CFonts.FONTFACE.lines; //last line is CFonts.FONTFACE.lines tall and is located at the bottom of the output array
for(let i = lines; i < output.length; i++) { //iterate over last line
let index = i - lines;
output[ i ] += Colorize( CFonts.FONTFACE.chars[ CHAR ][ index ] );
}
return output;
};
var $input = $SETTINGS.text; //text to be converted
var FONTS = '*console*block*simple*3d*simple3d*'; //all supported font files
var $font = {}; //the font object
OPTIONS.background = changeCase.upperCaseFirst(OPTIONS.background); //background color case convertion
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private function
// AddLetterSpacing, Add letter spacing for the next character
//
// @param output {array} The output array the line shall be appended to
//
// @return {array} The output array with space
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
const AddLetterSpacing = ( output ) => {
CFonts.debugging.report(`Running AddLetterSpacing`, 1);
if( FONTS.indexOf(OPTIONS.font) && OPTIONS.font !== 'console') { //getting font file
let lines = output.length - CFonts.FONTFACE.lines; //last line is CFonts.FONTFACE.lines tall and is located at the bottom of the output array
var fontFile = __dirname + '/fonts/' + OPTIONS.font + '.json';
$font = JSON.parse( fs.readFileSync(fontFile, 'utf8') );
for(let i = lines; i < output.length; i++) { //iterate over last line
let index = i - lines;
let space = Colorize( CFonts.FONTFACE.letterspace[ index ] )
}
else if(OPTIONS.font === 'console') { //writing in console text
if( space.length === 0 && CFonts.OPTIONS.letterSpacing > 0 ) {
CFonts.debugging.report(`AddLetterSpacing: Adding space to letter spacing`, 1);
var $write = $input.replace('|', "\n");
$font['colors'] = 0;
space = ' ';
}
}
else { //throw error if the font does not exist
console.log("\n" + ' Please use a font from the support stack: ' +
chalk.styles.green.open + '[ console | block | simple | 3d | simple3d ]' + chalk.styles.green.close + "\n");
process.exit(1);
}
output[ i ] += space.repeat( CFonts.OPTIONS.letterSpacing );
}
return output;
};
if(OPTIONS.font !== 'console') { //only render a font if it isn't the console font
var $output = [];
for(var i = 0, length = $font.lines; i < length; i++) { //create first lines with buffer
$output[i] = $font.buffer[i];
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private function
// Colorize, replace placeholders with color information
//
// @param character {string} The string to be converted
//
// @return {string} The character with color information for CLI
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
const Colorize = ( character ) => {
CFonts.debugging.report(`Running Colorize`, 1);
if( CFonts.FONTFACE.colors > 1 && character !== undefined ) {
for(let i = 0; i < CFonts.FONTFACE.colors; i++) { //convert all colors
let open = new RegExp(`<c${(i + 1)}>`, 'g');
let close = new RegExp(`</c${(i + 1)}>`, 'g');
let color = CFonts.OPTIONS.colors[ i ] || 'white';
character = character.replace( open, Chalk.styles[ color.toLowerCase() ].open );
character = character.replace( close, Chalk.styles[ color.toLowerCase() ].close );
}
}
var $charLength = 0; //use for max character per line
var $line = 0; //start with line 0
var $letterSpacing = "";
return character;
};
for(var i = 0, length = OPTIONS.letterSpacing; i < length; i++) { //letter spacing
$letterSpacing += colorize($font, OPTIONS, $font.letterspace[i]);
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private function
// AlignText, calculate the spaces to be added to the left of each line to align them either center or right
//
// @param output {array} The output array the line shall be appended to
// @param lineLength {integer} the current line length
//
// @return {array} The output array with space added on the left for alignment
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
const AlignText = ( output, lineLength ) => {
CFonts.debugging.report(`Running AlignText`, 1);
let space = 0;
if( CFonts.OPTIONS.align === 'center' ) { //calculate the size for center alignment
space = Math.floor(( WinSize.width - lineLength ) / 2);
CFonts.debugging.report(`AlignText: Center lineLength: ${lineLength}, WinSize.width: ${WinSize.width}, space: ${space}`, 2);
}
if( CFonts.OPTIONS.align === 'right' ) { //calculate the size for right alignment
space = WinSize.width - lineLength;
for(var i = 0, length = $input.length; i < length; i++) { //iterate through the message
CFonts.debugging.report(`AlignText: Right lineLength: ${lineLength}, WinSize.width: ${WinSize.width}, space: ${space}`, 2);
}
var $char = $input.charAt(i).toUpperCase(); //only upper case is supported at this time
if($charLength >= OPTIONS.maxLength || $char === "|") { //jump to next line after OPTIONS.maxLength characters or when line break is found
$charLength = 0;
$line += $font.lines;
if( space > 0 ) { //only add if there is something to add
let lines = output.length - CFonts.FONTFACE.lines; //last line is CFonts.FONTFACE.lines tall and is located at the bottom of the output array
space = ' '.repeat( space );
for(var l = $line, lll = $line + $font.lines; l < lll; l++) { //create new lines with buffer
$output[l] = $font.buffer[ (l - $line) ];
for(let i = lines; i < output.length; i++) { //iterate over last line
output[ i ] = space + output[ i ];
}
}
return output;
};
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
return {
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// settings
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
DEBUG: false, //Debug setting
DEBUGLEVEL: 2, //Debug level setting
COLORS: [ //All allowed font colors
'black',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
'gray',
],
BGCOLORS: [ //All allowed background colors
'black',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
],
ALIGNMENT: [ //All allowed alignment options
'left',
'center',
'right',
],
FONTFACES: [ //All allowed fonts
'console',
'block',
'simpleBlock',
'simple',
'3d',
'simple3d',
],
FONTFACE: {}, //Font face object to be filled with selected fontface
OPTIONS: {}, //User options
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public function
// say, main method to write out your string
//
// @param INPUT {string} The string you want to write out
// @param SETTINGS {object} (optional) Settings object
// font {string} Font face, Default 'block'
// align {string} Text alignment, Default: 'left'
// colors {array} Colors for font, Default: []
// background {string} Chalk color string for background, Default 'Black'
// letterSpacing {integer} Space between letters, Default: set by selected font face
// lineHeight {integer} Space between lines, Default: 1
// space {boolean} Output space before and after output, Default: true
// maxLength {integer} Maximum amount of characters per line, Default width of console window
//
// @return {string} CLI output of INPUT
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
say: ( INPUT = '', SETTINGS = {} ) => {
CFonts.debugging.report(`Running say`, 1);
let write = ''; //output to be build
CFonts.OPTIONS = { //SETTINGS and defaults
font: SETTINGS.font || 'block',
align: SETTINGS.align || 'left',
colors: SETTINGS.colors || [],
background: ChangeCase.upperCaseFirst( SETTINGS.background ) || 'Black',
letterSpacing: SETTINGS.letterSpacing === undefined ? 1 : SETTINGS.letterSpacing,
lineHeight: SETTINGS.lineHeight === undefined ? 1 : parseInt( SETTINGS.lineHeight ),
space: SETTINGS.space === undefined ? true : SETTINGS.space,
maxLength: SETTINGS.maxLength || 0,
};
if( INPUT === undefined || INPUT === '' ) {
CFonts.log.error(`Please provide text to convert`);
process.exit(1); //exit program with failure code
}
for( let color in CFonts.OPTIONS.colors ) { //check color usage
if( CFonts.COLORS.indexOf( CFonts.OPTIONS.colors[ color ] ) === -1 ) {
CFonts.log.error(
`"${Chalk.red( CFonts.OPTIONS.colors[ color ] )}" is not a valid font color option.\n` +
`Please use a color from the supported stack:\n${Chalk.green(`[ ${CFonts.COLORS.join(' | ')} ]`)}`
);
process.exit(1); //exit program with failure code
}
}
if( $font.chars[ $char ] !== undefined) { //make sure this character exists in the font
$charLength++; //counting all printed characters
if( CFonts.BGCOLORS.indexOf( CFonts.OPTIONS.background.toLowerCase() ) === -1 ) {
CFonts.log.error(
`"${Chalk.red( CFonts.OPTIONS.background )}" is not a valid background option.\n` +
`Please use a color from the supported stack:\n${Chalk.green(`[ ${CFonts.BGCOLORS.join(' | ')} ]`)}`
);
var charWidth = equalWidth( $font.chars[ $char ] );
process.exit(1); //exit program with failure code
}
for(var c = 0, l = $font.lines; c < l; c++) { //iterate over font face lines
if( CFonts.ALIGNMENT.indexOf( CFonts.OPTIONS.align ) === -1 ) {
CFonts.log.error(
`"${Chalk.red( CFonts.OPTIONS.align )}" is not a valid alignment option.\n` +
`Please use an alignment option from the supported stack:\n${Chalk.green(`[ ${CFonts.ALIGNMENT.join(' | ')} ]`)}`
);
var $character = $font.chars[ $char ][c];
process.exit(1); //exit program with failure code
}
if( $character.length < charWidth ) {
for(var w = (charWidth - $character.length) - 1; w >= 0; w--) {
$character += ' ';
};
//log OPTIONS for debugging
if( CFonts.DEBUG ) {
let outOption = `OPTIONS:\n Text: ${INPUT}`;
for( let key in CFonts.OPTIONS ) {
outOption += `\n Options.${key}: ${CFonts.OPTIONS[ key ]}`;
}
CFonts.debugging.report( outOption, 2 );
}
if( CFonts.OPTIONS.font === 'console' ) { //console fontface is pretty easy to process
let color = CFonts.OPTIONS.colors[0].toLowerCase() || 'white'; //font color
let lines = INPUT.split('|'); //each line
let output = []
CFonts.FONTFACE.lines = 1;
for(let line in lines) {
let length = lines[ line ].length;
lines[ line ] = Chalk[ color ]( lines[ line ] );
output.push( lines[ line ] );
output = AlignText( output, length ); //calculate alignment based on lineLength
}
write = output.join(`\n`); //convert to one line
}
else { //all other fontfaces need the font-file and some more work
GetFont( CFonts.OPTIONS.font ); //get fontface object and make it global
//setting the letterspacing preference from font face if there is no user overwrite
if( SETTINGS.letterSpacing === undefined ) {
CFonts.debugging.report(`Looking up letter spacing from font face`, 1);
let width = 0;
for( let i in CFonts.FONTFACE.letterspace ) {
let char = CFonts.FONTFACE.letterspace[ i ].replace(/(<([^>]+)>)/ig, ''); //get character and strip color infos
if( width < char.length ) {
width = char.length;
}
}
$character = colorize($font, OPTIONS, $character);
CFonts.debugging.report(`Letter spacing set to font face default: "${width}"`, 2);
CFonts.OPTIONS.letterSpacing = width;
}
$output[ ($line + c) ] += $character + $letterSpacing; //save output per character
let output = AddLine( [] ); //create first lines with buffer
let lineLength = CharLength( CFonts.FONTFACE.buffer ); //count each output character per line and start with the buffer
let maxChars = 0; //count each character we print for maxLength option
output = AddLetterSpacing( output ); //add letter spacing to the beginning
lineLength += CharLength( CFonts.FONTFACE.letterspace ) * CFonts.OPTIONS.letterSpacing; //count the space for the letter spacing
for(let i = 0; i < INPUT.length; i++) { //iterate through the message
let CHAR = INPUT.charAt( i ).toUpperCase(); //the current character we convert, only upper case is supported at this time
if( CFonts.FONTFACE.chars[ CHAR ] === undefined && CHAR !== `|` ) { //make sure this character exists in the font
CFonts.debugging.error(`Character not found in font: "${CHAR}"`, 2); //fail silently
}
else {
CFonts.debugging.report(`Character found in font: "${CHAR}"`, 2);
let lastLineLength = lineLength; //we need the lineLength for alignment before we look up if the next char fits
if( CHAR !== `|` ) { //what will the line length be if we add the next char?
lineLength += CharLength( CFonts.FONTFACE.chars[ CHAR ] ); //get the length of this character
lineLength += CharLength( CFonts.FONTFACE.letterspace ) * CFonts.OPTIONS.letterSpacing; //new line, new line length
}
//jump to next line after OPTIONS.maxLength characters or when line break is found or the console windows would has ran out of space
if(maxChars >= CFonts.OPTIONS.maxLength && CFonts.OPTIONS.maxLength != 0 || CHAR === `|` || lineLength > WinSize.width) {
CFonts.debugging.report(
`NEWLINE: maxChars: ${maxChars}, ` +
`CFonts.OPTIONS.maxLength: ${CFonts.OPTIONS.maxLength}, ` +
`CHAR: ${CHAR}, ` +
`lineLength: ${lineLength}, ` +
`WinSize.width: ${WinSize.width} `, 2
);
output = AlignText( output, lastLineLength ); //calculate alignment based on lineLength
lineLength = CharLength( CFonts.FONTFACE.buffer ); //new line: new line length
lineLength += CharLength( CFonts.FONTFACE.letterspace ) * CFonts.OPTIONS.letterSpacing; //each new line starts with letter spacing
if( CHAR !== `|` ) { //if this is a character
lineLength += CharLength( CFonts.FONTFACE.chars[ CHAR ] ); //get the length of this character
lineLength += CharLength( CFonts.FONTFACE.letterspace ) * CFonts.OPTIONS.letterSpacing; //add letter spacing at the end
}
maxChars = 0; //new line, new maxLength goal
output = AddLine( output ); //adding new line
output = AddLetterSpacing( output ); //add letter spacing to the beginning
}
CFonts.debugging.report(`lineLength at: "${lineLength}"`, 2);
if( CHAR !== `|` ) {
maxChars++; //counting all printed characters
output = AddChar( CHAR, output ); //add new character
output = AddLetterSpacing( output ); //add letter spacing
}
}
}
output = AlignText( output, lineLength ); //alignment last line
write = output.join(`\n`); //convert to one line
}
}
if( CFonts.FONTFACE.colors <= 1 ) { //add text color if only one
let color = CFonts.OPTIONS.colors[0] || `white`;
var $write = $output.join("\n"); //convert to one line
}
write = Chalk[ color.toLowerCase() ]( write );
}
if($font.colors <= 1) { //add text color if only one
var color = OPTIONS.colors[0] || "white";
if( CFonts.OPTIONS.space ) { //add space
write = `\n\n` + write + `\n\n`;
}
$write = chalk.styles[color.toLowerCase()].open + $write + chalk.styles[color.toLowerCase()].close;
}
console.log( Chalk[ 'bg' + CFonts.OPTIONS.background ]( write ) ); //write out
},
if(OPTIONS.space) { //add space
$write = "\n\n" + $write + "\n\n";
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Debugging prettiness
//
// debugging, Print debug message that will be logged to console.
//
// @method headline Return a headline preferably at the beginning of your app
// @param [text] {string} The sting you want to log
// @param [level] {integer} (optional) The debug level. Show equal and greater levels. Default: 99
// @return [ansi] {output}
//
// @method report Return a message to report starting a process
// @param [text] {string} The sting you want to log
// @param [level] {integer} (optional) The debug level. Show equal and greater levels. Default: 99
// @return [ansi] {output}
//
// @method error Return a message to report an error
// @param [text] {string} The sting you want to log
// @param [level] {integer} (optional) The debug level. Show equal and greater levels. Default: 99
// @return [ansi] {output}
//
// @method interaction Return a message to report an interaction
// @param [text] {string} The sting you want to log
// @param [level] {integer} (optional) The debug level. Show equal and greater levels. Default: 99
// @return [ansi] {output}
//
// @method send Return a message to report data has been sent
// @param [text] {string} The sting you want to log
// @param [level] {integer} (optional) The debug level. Show equal and greater levels. Default: 99
// @return [ansi] {output}
//
// @method received Return a message to report data has been received
// @param [text] {string} The sting you want to log
// @param [level] {integer} (optional) The debug level. Show equal and greater levels. Default: 99
// @return [ansi] {output}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
debugging: {
console.log( chalk['bg' + OPTIONS.background]( $write ) ); //write out
headline: ( text, level = 99 ) => {
if( CFonts.DEBUG && level >= CFonts.DEBUGLEVEL ) {
console.log(
Chalk.bgWhite(`\n${Chalk.bold(' \u2611 ')} ${text}`)
);
}
},
}
report: ( text, level = 99 ) => {
if( CFonts.DEBUG && level >= CFonts.DEBUGLEVEL ) {
console.log(
Chalk.bgWhite(`\n${Chalk.bold.green(' \u2611 ')} ${Chalk.black(`${text} `)}`)
);
}
},
error: ( text, level = 99 ) => {
if( CFonts.DEBUG && level >= CFonts.DEBUGLEVEL ) {
console.log(
Chalk.bgWhite(`\n${Chalk.red(' \u2612 ')} ${Chalk.black(`${text} `)}`)
);
}
},
interaction: ( text, level = 99 ) => {
if( CFonts.DEBUG && level >= CFonts.DEBUGLEVEL ) {
console.log(
Chalk.bgWhite(`\n${Chalk.blue(' \u261C ')} ${Chalk.black(`${text} `)}`)
);
}
},
send: ( text, level = 99 ) => {
if( CFonts.DEBUG && level >= CFonts.DEBUGLEVEL ) {
console.log(
Chalk.bgWhite(`\n${Chalk.bold.cyan(' \u219D ')} ${Chalk.black(`${text} `)}`)
);
}
},
received: ( text, level = 99 ) => {
if( CFonts.DEBUG && level >= CFonts.DEBUGLEVEL ) {
console.log(
Chalk.bgWhite(`\n${Chalk.bold.cyan(' \u219C ')} ${Chalk.black(`${text} `)}`)
);
}
}
},
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Logging prettiness
//
// log, Print error message to console.
//
// @method error Return a headline preferably at the beginning of your app
// @param [text] {string} The sting you want to log
// @return [ansi] {output}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
log: {
error: ( text ) => {
text = text.replace(/(?:\r\n|\r|\n)/g, '\n '); //indent each line
console.log(`\n ${Chalk.bold.red('Ouch:')} ${text}\n`);
},
},
}
})();
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Module export
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
module.exports = cfonts;
module.exports = CFonts;
{
"name": "cfonts",
"description": "Sexy fonts for the console",
"version": "0.0.13",
"version": "1.0.0",
"homepage": "https://github.com/dominikwilkowski/cfonts",

@@ -11,2 +11,7 @@ "author": {

},
"contributors": {
"name": "Dominik Wilkowski",
"email": "Hi@Dominik-Wilkowski.com",
"url": "http://dominik-wilkowski.com/"
},
"repository": {

@@ -26,3 +31,3 @@ "type": "git",

"engines": {
"node": ">= 0.8.0"
"node": ">=6.0.0"
},

@@ -33,11 +38,12 @@ "scripts": {

"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "^0.9.2",
"grunt-exec": "^0.4.6"
"grunt": "~1.0.1",
"grunt-contrib-jshint": "^1.0.0",
"grunt-exec": "^1.0.0"
},
"peerDependencies": {},
"dependencies": {
"change-case": "^2.1.6",
"chalk": "^1.0.0",
"commander": "^2.6.0"
"change-case": "^3.0.0",
"commander": "^2.6.0",
"window-size": "^0.2.0"
},

@@ -57,3 +63,3 @@ "keywords": [

},
"license": "GNU-GPL"
}
"license": "GNU-GPLv2"
}
```shell
██████╗ ███████╗ ██████╗ ███╗ ██╗ ████████╗ ███████╗
██╔════╝ ██╔════╝ ██╔═══██╗ ████╗ ██║ ╚══██╔══╝ ██╔════╝
██║ █████╗ ██║ ██║ ██╔██╗ ██║ ██║ ███████╗
██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║
╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║
╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝
██████╗ ███████╗ ██████╗ ███╗ ██╗ ████████╗ ███████╗
██╔════╝ ██╔════╝ ██╔═══██╗ ████╗ ██║ ╚══██╔══╝ ██╔════╝
██║ █████╗ ██║ ██║ ██╔██╗ ██║ ██║ ███████╗
██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║
╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║
╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝
```

@@ -13,3 +13,3 @@

> This is a silly little command line tool for sexy fonts in the console.
> This is a silly little command line tool for sexy fonts in the console. **Give your cli some love.**

@@ -32,22 +32,31 @@ ## Examples

```shell
$ sudo npm install cfonts -g
$ npm install cfonts -g
```
To use it in your project:
To use it in your shell:
```shell
$ cfonts "Hello|World\!"
```
_Remember to escape the `!` character with `\` in the shell_
Or use it in your project:
```js
var FONTS = require('cfonts');
var CFonts = require('cfonts');
var fonts = new FONTS({
'text': 'Hello World', //text to be converted
'font': 'block', //define the font face
'colors': '', //define all colors
'background': 'Black', //define the background color
'letterSpacing': 1, //define letter spacing
'space': true, //define if the output text should have empty lines on top and on the bottom
'maxLength': '10' //define how many character can be on one line
CFonts.say('Hello|world!', {
'font': 'block', //define the font face
'align': 'left', //define text alignment
'colors': ['white'], //define all colors
'background': 'Black', //define the background color
'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
});
```
_Remember to escape the `!` character with `\` in the shell_
_All settings are optional and shown here with their default_

@@ -60,3 +69,3 @@

```
Usage: cfonts <command> <param1>,<param2> <command> <param1> etc...
Usage: cfonts "<value>" [option1] <input1> [option2] <input1>,<input2> [option3] etc...
```

@@ -135,3 +144,3 @@

#### -h, --help
Type: `<command>`
Type: `<command>`
Default value: `none`

@@ -147,3 +156,3 @@

#### -V, --version
Type: `<command>`
Type: `<command>`
Default value: `none`

@@ -158,4 +167,4 @@

#### -t, --text
Type: `<string>`
#### text
Type: `<string>`
Default value: `""`

@@ -166,3 +175,3 @@

```shell
$ cfonts --text "Hello world!"
$ cfonts "Hello world"
```

@@ -172,3 +181,3 @@

#### -f, --font
Type: `<string>`
Type: `<string>`
Default value: `"block"`

@@ -178,19 +187,35 @@

* `console` [colors: 1]
* `block` [colors: 2]
* `simple` [colors: 1]
* `3d` [colors: 2]
* `simple3d` [colors: 1]
- `console` [colors: 1]
- `block` [colors: 2] _(default)_
- `simpleBlock` [colors: 1]
- `simple` [colors: 1]
- `3d` [colors: 2]
- `simple3d` [colors: 1]
```shell
$ cfonts --font "block"
$ cfonts "text" -f "block3d"
```
#### -a, --align
Type: `<string>`
Default value: `"left"`
You can align your text in the terminal with this option. Use the keywords below:
- `left` _(default)_
- `center`
- `right`
```shell
$ cfonts "text" -a "center"
```
#### -c, --colors
Type: `<string list>`
Type: `<string list>`
Default value: `[]`
In this setting you can set the colors for each font face. Use the below color strings build in by [chalk](https://github.com/sindresorhus/chalk).
Provide colors in a comma-separated string, eg: `red,blue`
With this setting you can set the colors for your font. Use the below color strings built in by [chalk](https://github.com/sindresorhus/chalk).
Provide colors in a comma-separated string, eg: `red,blue` _(no spaces)_

@@ -204,7 +229,7 @@ - `black`

- `cyan`
- `white`
- `white` _(default)_
- `gray`
```shell
$ cfonts --colors white,blue
$ cfonts "text" --colors white,blue
```

@@ -214,9 +239,9 @@

#### -b, --background
Type: `<string>`
Type: `<string>`
Default value: `"Black"`
In this setting you can set the background colors for the output. Use the below color strings build in by [chalk](https://github.com/sindresorhus/chalk).
Provide the background color from the below supported list, eg: 'white'
With this setting you can set the background colors for the output. Use the below color strings built in by [chalk](https://github.com/sindresorhus/chalk).
Provide the background color from the below supported list, eg: 'White'
- `Black`
- `Black` _(default)_
- `Red`

@@ -231,3 +256,3 @@ - `Green`

```shell
$ cfonts --background "Green"
$ cfonts "text" --background "Green"
```

@@ -237,3 +262,3 @@

#### -l, --letter-spacing
Type: `<integer>`
Type: `<integer>`
Default value: `1`

@@ -244,8 +269,19 @@

```shell
$ cfonts --letter-spacing 2
$ cfonts "text" --letter-spacing 2
```
#### -s, --space
Type: `<boolen>`
#### -z, --line-height
Type: `<integer>`
Default value: `1`
Set this option to widen the space between lines.
```shell
$ cfonts "text" --line-height 2
```
#### -s, --spaceless
Type: `<boolen>`
Default value: `true`

@@ -256,3 +292,3 @@

```shell
$ cfonts --space false
$ cfonts "text" --spaceless
```

@@ -262,10 +298,9 @@

#### -m, --max-length
Type: `<integer>`
Default value: `10`
Type: `<integer>`
Default value: `0`
This option sets the maximum characters that will be printed on one line. As the shell usually doesn't give you access to its width, this is nessesary
to not end up with a scrambled text output.
This option sets the maximum characters that will be printed on one line. 0 means no max width and the text will break at the edge of the terminal window.
```shell
$ cfonts --max-length 15
$ cfonts "text" --max-length 15
```

@@ -279,2 +314,3 @@

## Release History
* 1.0.0 - refactor, added alignment and line height option, new cli commands, added simpleBlock
* 0.0.13 - fixed simple3d

@@ -296,2 +332,2 @@ * 0.0.12 - fixed simple3d and added to grunt test

## License
Copyright (c) 2015 Dominik Wilkowski. Licensed under the [GNU GPL](https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE).
Copyright (c) 2016 Dominik Wilkowski. Licensed under the [GNU GPLv2](https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc