From afd3513b30fe82ade5dcce2d182f26078eb46290 Mon Sep 17 00:00:00 2001 From: Dominik Wilkowski Date: Thu, 30 Jun 2016 15:27:32 +1000 Subject: [PATCH] refactored, added alignment, fixed dominikwilkowski/cfonts#2, added line height, added simpleBlock Signed-off-by: Dominik Wilkowski --- Gruntfile.js | 27 +- README.md | 144 ++++++---- bin/font.js | 118 +++++--- fonts/3d.json | 2 +- fonts/block.json | 2 +- fonts/simple.json | 2 +- fonts/simple3d.json | 522 +++++++++++++++++----------------- fonts/simpleBlock.json | 516 +++++++++++++++++++++++++++++++++ img/example1.png | Bin 4503 -> 7648 bytes index.js | 626 ++++++++++++++++++++++++++++++++++------- package.json | 24 +- 11 files changed, 1508 insertions(+), 475 deletions(-) mode change 100644 => 100755 bin/font.js create mode 100644 fonts/simpleBlock.json diff --git a/Gruntfile.js b/Gruntfile.js index aae9e96e..b2c07e8f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -37,22 +37,27 @@ module.exports = function(grunt) { // TEST //---------------------------------------------------------------------------------------------------------------------------------------------------------- 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', + }, }); diff --git a/README.md b/README.md index 1e4187a8..5a54e8ef 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ ```shell - ██████╗ ███████╗ ██████╗ ███╗ ██╗ ████████╗ ███████╗ - ██╔════╝ ██╔════╝ ██╔═══██╗ ████╗ ██║ ╚══██╔══╝ ██╔════╝ - ██║ █████╗ ██║ ██║ ██╔██╗ ██║ ██║ ███████╗ - ██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║ - ╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║ - ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ + ██████╗ ███████╗ ██████╗ ███╗ ██╗ ████████╗ ███████╗ + ██╔════╝ ██╔════╝ ██╔═══██╗ ████╗ ██║ ╚══██╔══╝ ██╔════╝ + ██║ █████╗ ██║ ██║ ██╔██╗ ██║ ██║ ███████╗ + ██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║ + ╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║ + ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ``` [![NPM](https://nodei.co/npm/cfonts.png?downloads=true)](https://nodei.co/npm/cfonts/) -> 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.** ## Examples @@ -28,26 +28,35 @@ Real world example: To install the CLI app, simply NPM install it globally. ```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 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 +var CFonts = require('cfonts'); + +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_ ## Usage @@ -55,7 +64,7 @@ _Remember to escape the `!` character with `\` in the shell_ Using the CLI is easy. ``` -Usage: cfonts , etc... +Usage: cfonts "" [option1] [option2] , [option3] etc... ``` At any point you can run the *help* command to get a full list of commands and @@ -129,7 +138,7 @@ _The `|` character will be replaced with a line break_ ## Options #### -h, --help -Type: `` +Type: `` Default value: `none` This shows a list of all available options. @@ -140,7 +149,7 @@ $ cfonts --help #### -V, --version -Type: `` +Type: `` Default value: `none` This shows the installed version. @@ -150,40 +159,56 @@ $ cfonts --version ``` -#### -t, --text -Type: `` +#### text +Type: `` Default value: `""` This is the "textinput" to be converted into a nice font ```shell -$ cfonts --text "Hello world!" +$ cfonts "Hello world" ``` #### -f, --font -Type: `` +Type: `` Default value: `"block"` This is the font face you want to use. So far this plugin ships with with following font faces: -* `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: `` +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: `` +Type: `` 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)_ - `black` - `red` @@ -192,22 +217,22 @@ Provide colors in a comma-separated string, eg: `red,blue` - `blue` - `magenta` - `cyan` -- `white` +- `white` _(default)_ - `gray` ```shell -$ cfonts --colors white,blue +$ cfonts "text" --colors white,blue ``` #### -b, --background -Type: `` +Type: `` 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` - `Green` - `Yellow` @@ -217,41 +242,51 @@ Provide the background color from the below supported list, eg: 'white' - `White` ```shell -$ cfonts --background "Green" +$ cfonts "text" --background "Green" ``` #### -l, --letter-spacing -Type: `` +Type: `` Default value: `1` Set this option to widen the space between characters. ```shell -$ cfonts --letter-spacing 2 +$ cfonts "text" --letter-spacing 2 +``` + + +#### -z, --line-height +Type: `` +Default value: `1` + +Set this option to widen the space between lines. + +```shell +$ cfonts "text" --line-height 2 ``` -#### -s, --space -Type: `` +#### -s, --spaceless +Type: `` Default value: `true` Set this option to false if you don't want the plugin to insert two empty lines on top and on the bottom of the output. ```shell -$ cfonts --space false +$ cfonts "text" --spaceless ``` #### -m, --max-length -Type: `` -Default value: `10` +Type: `` +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 ``` @@ -260,6 +295,7 @@ Please look at the coding style and work with it, not against it ;) ## Release History +* 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 @@ -276,4 +312,4 @@ Please look at the coding style and work with it, not against it ;) ## License -Copyright (c) 2015 Dominik Wilkowski. Licensed under the [GNU GPL](https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE). \ No newline at end of file +Copyright (c) 2016 Dominik Wilkowski. Licensed under the [GNU GPLv2](https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE). \ No newline at end of file diff --git a/bin/font.js b/bin/font.js old mode 100644 new mode 100755 index 8d06a534..feeb6d06 --- a/bin/font.js +++ b/bin/font.js @@ -1,11 +1,15 @@ #!/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 + * + **************************************************************************************************************************************************************/ 'use strict'; @@ -13,55 +17,87 @@ //-------------------------------------------------------------------------------------------------------------------------------------------------------------- // Dependencies //-------------------------------------------------------------------------------------------------------------------------------------------------------------- -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(`"" [option1] [option2] , [option3]`) + .option(`-f, --font `, `define "font face"`, `block`) + .option(`-a, --align `, `define "alignment" for the text`, `left`) + .option(`-c, --colors ,...`, `provide colors for text`, `white`) + .option(`-b, --background `, `provide background color`, `Black`) + .option(`-l, --letter-spacing `, `define letter spacing {integer}`) + .option(`-z, --line-height `, `define line height {integer}`, 1) + .option(`-s, --spaceless`, `surpress space on top and on the bottom`) + .option(`-m, --max-length `, `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] [options2] ,') - .option('-t, --text ', '"textinput" to be converted into a nice font') - .option('-f, --font ', '"fontname" to be used') - .option('-c, --colors ,...', 'provide colors in format: red,blue etc.', list) - .option('-b, --background ', 'provide background color in format: \'white\'') - .option('-l, --letter-spacing ', 'letterSpacing to be used as integer') - .option('-s, --space ', 'define if the output text should have empty lines on top and on the bottom') - .option('-m, --max-length \\", " /\\___/", - " \\/__/" + " \\/__/ " ], "Z": [ - "", - " ____", - "/\\_ ,`\\", - "\\/_/ /_", + " ", + " ____ ", + "/\\_ ,`\\ ", + "\\/_/ /_ ", " /\\____\\", " \\/____/", - "" + " " ], "0": [ - " __", - " /'__`\\", - "/\\ \\/\\ \\", - "\\ \\ \\ \\ \\", + " __ ", + " /'__`\\ ", + "/\\ \\/\\ \\ ", + "\\ \\ \\ \\ \\ ", " \\ \\ \\_\\ \\", " \\ \\____/", - " \\/___/" + " \\/___/ " ], "1": [ - " _", - " /' \\", - "/\\_, \\", - "\\/_/\\ \\", - " \\ \\ \\", + " _ ", + " /' \\ ", + "/\\_, \\ ", + "\\/_/\\ \\ ", + " \\ \\ \\ ", " \\ \\_\\", " \\/_/" ], "2": [ - " ___", - " /'___`\\", - "/\\_\\ /\\ \\", - "\\/_/// /__", + " ___ ", + " /'___`\\ ", + "/\\_\\ /\\ \\ ", + "\\/_/// /__ ", " // /_\\ \\", " /\\______/", - " \\/_____/" + " \\/_____/ " ], "3": [ - " __", - " /'__`\\", - "/\\_\\L\\ \\", - "\\/_/_\\_<_", + " __ ", + " /'__`\\ ", + "/\\_\\L\\ \\ ", + "\\/_/_\\_<_ ", " /\\ \\L\\ \\", " \\ \\____/", - " \\/___/" + " \\/___/ " ], "4": [ - " __ __", - "/\\ \\\\ \\", - "\\ \\ \\\\ \\", - " \\ \\ \\\\ \\_", + " __ __ ", + "/\\ \\\\ \\ ", + "\\ \\ \\\\ \\ ", + " \\ \\ \\\\ \\_ ", " \\ \\__ ,__\\", " \\/_/\\_\\_/", - " \\/_/" + " \\/_/ " ], "5": [ - " ______", - "/\\ ___\\", - "\\ \\ \\__/", - " \\ \\___``\\", + " ______ ", + "/\\ ___\\ ", + "\\ \\ \\__/ ", + " \\ \\___``\\ ", " \\/\\ \\L\\ \\", " \\ \\____/", - " \\/___/" + " \\/___/ " ], "6": [ - " ____", - " /'___\\", - "/\\ \\__/", - "\\ \\ _``\\", + " ____ ", + " /'___\\ ", + "/\\ \\__/ ", + "\\ \\ _``\\ ", " \\ \\ \\L\\ \\", " \\ \\____/", - " \\/___/" + " \\/___/ " ], "7": [ - " ________", + " ________ ", "/\\____ \\", "\\/___/' /'", - " /' /'", - " /' /'", - " /\\_/", - " \\//" + " /' /' ", + " /' /' ", + " /\\_/ ", + " \\// " ], "8": [ - " __", - " /' _`\\", - "/\\ \\L\\ \\", - "\\/_> _ <_", + " __ ", + " /' _`\\ ", + "/\\ \\L\\ \\ ", + "\\/_> _ <_ ", " /\\ \\L\\ \\", " \\ \\____/", - " \\/___/" + " \\/___/ " ], "9": [ - " __", - " /'_ `\\", - "/\\ \\L\\ \\", - "\\ \\___, \\", - " \\/__,/\\ \\", + " __ ", + " /'_ `\\ ", + "/\\ \\L\\ \\ ", + "\\ \\___, \\ ", + " \\/__,/\\ \\ ", " \\ \\_\\", " \\/_/" ], "!": [ - " __", - "/\\ \\", - "\\ \\ \\", - " \\ \\ \\", - " \\ \\_\\", + " __ ", + "/\\ \\ ", + "\\ \\ \\ ", + " \\ \\ \\ ", + " \\ \\_\\ ", " \\/\\_\\", " \\/_/" ], "?": [ - " _", - " /'_`\\", + " _ ", + " /'_`\\ ", "/\\_\\/\\`\\", "\\/_//'/'", - " /\\_\\", + " /\\_\\ ", " \\/\\_\\", " \\/_/" ], ".": [ - "", - "", - "", - "", - " __", + " ", + " ", + " ", + " ", + " __ ", "/\\_\\", "\\/_/" ], "+": [ - " __", - " /\\ \\", - " \\_\\ \\___", + " __ ", + " /\\ \\ ", + " \\_\\ \\___ ", "/\\___ __\\", "\\/__/\\ \\_/", - " \\ \\_\\", - " \\/_/" + " \\ \\_\\ ", + " \\/_/ " ], "-": [ - "", - "", - " _______", + " ", + " ", + " _______ ", "/\\______\\", "\\/______/", - "", - "" + " ", + " " ], "_": [ - "", - "", - "", - "", - " _______", + " ", + " ", + " ", + " ", + " _______ ", " /\\______\\", " \\/______/" ], "=": [ - "", - " _______", - "/\\______\\", - "\\/______/_", + " ", + " _______ ", + "/\\______\\ ", + "\\/______/_ ", " /\\______\\", " \\/______/", - "" + " " ], "@": [ - " __", - " /'_`\\_", - " /'/'_` \\", - "/\\ \\ \\L\\ \\", + " __ ", + " /'_`\\_ ", + " /'/'_` \\ ", + "/\\ \\ \\L\\ \\ ", "\\ \\ `\\__,_\\", " \\ `\\_____\\", " `\\/_____/" ], "#": [ - " __ __", - " _\\ \\\\ \\__", - "/\\__ _ _\\", - "\\/_L\\ \\\\ \\L_", + " __ __ ", + " _\\ \\\\ \\__ ", + "/\\__ _ _\\ ", + "\\/_L\\ \\\\ \\L_ ", " /\\_ _ _\\", " \\/_/\\_\\\\_\\/", - " \\/_//_/" + " \\/_//_/ " ], "$": [ - " _", - " /|_\\_", - " /' _ `\\", + " _ ", + " /|_\\_ ", + " /' _ `\\ ", " \\ \\___ \\", " \\ `\\_ _/", " `\\_/\\_\\", " \\/_/" ], "%": [ - " __ __", - "/\\_\\ /\\_\\", - "\\/_/ / / /", - " / / /", - " / / / __", + " __ __ ", + "/\\_\\ /\\_\\ ", + "\\/_/ / / / ", + " / / / ", + " / / / __ ", " / / / /\\_\\", " \\/_/ \\/_/" ], "&": [ - " ____", - " /| _ \\", - " |/\\ ` |", - " \\ / __`\\/\\", + " ____ ", + " /| _ \\ ", + " |/\\ ` | ", + " \\ / __`\\/\\ ", " /| \\L> <_", " | \\_____/\\/", " \\/____/\\/ " ], "(": [ - " _", - " /' \\", - "/\\ ,/", - "\\ \\ \\", - " \\ \\ `\\", + " _ ", + " /' \\ ", + "/\\ ,/ ", + "\\ \\ \\ ", + " \\ \\ `\\ ", " \\ `\\__\\", - " `\\/_/" + " `\\/_/ " ], ")": [ - " __", - "/\\ `\\", - "\\`\\ \\", - " `\\`\\ \\", + " __ ", + "/\\ `\\ ", + "\\`\\ \\ ", + " `\\`\\ \\ ", " `\\/' \\", " /\\__/", - " \\/_/" + " \\/_/ " ], "/": [ - " __", + " __ ", " /\\_\\", " / / /", - " / / /", - " / / /", - "/ / /", - "\\/_/" + " / / / ", + " / / / ", + "/ / / ", + "\\/_/ " ], ":": [ - "", - " __", - "/\\_\\", - "\\/_/_", + " ", + " __ ", + "/\\_\\ ", + "\\/_/_ ", " /\\_\\", " \\/_/", - "" + " " ], ";": [ - "", - " __", - "/\\_\\", - "\\/_/_", + " ", + " __ ", + "/\\_\\ ", + "\\/_/_ ", " /\\ \\", " \\ \\/", - " \\/" + " \\/ " ], " ": [ " ", diff --git a/fonts/simpleBlock.json b/fonts/simpleBlock.json new file mode 100644 index 00000000..d452fac2 --- /dev/null +++ b/fonts/simpleBlock.json @@ -0,0 +1,516 @@ +{ + "name": "simpleBlock", + "version": "0.0.1", + "homepage": "https://github.com/dominikwilkowski/cfonts", + "colors": 1, + "lines": 7, + "buffer": [ + "", + "", + "", + "", + "", + "", + "" + ], + "letterspace": [ + " ", + " ", + " ", + " ", + " ", + " ", + " " + ], + "chars": { + "A": [ + " ", + " _|_| ", + " _| _|", + " _|_|_|_|", + " _| _|", + " _| _|", + " " + ], + "B": [ + " ", + " _|_|_| ", + " _| _|", + " _|_|_| ", + " _| _|", + " _|_|_| ", + " ", + " " + ], + "C": [ + " ", + " _|_|_|", + " _| ", + " _| ", + " _| ", + " _|_|_|", + " " + ], + "D": [ + " ", + " _|_|_| ", + " _| _|", + " _| _|", + " _| _|", + " _|_|_| ", + " " + ], + "E": [ + " ", + " _|_|_|_|", + " _| ", + " _|_|_| ", + " _| ", + " _|_|_|_|", + " " + ], + "F": [ + " ", + " _|_|_|_|", + " _| ", + " _|_|_| ", + " _| ", + " _| ", + " " + ], + "G": [ + " ", + " _|_|_|", + " _| ", + " _| _|_|", + " _| _|", + " _|_|_|", + " " + ], + "H": [ + " ", + " _| _|", + " _| _|", + " _|_|_|_|", + " _| _|", + " _| _|", + " " + ], + "I": [ + " ", + " _|_|_|", + " _| ", + " _| ", + " _| ", + " _|_|_|", + " " + ], + "J": [ + " ", + " _|", + " _|", + " _|", + " _| _|", + " _|_| ", + " " + ], + "K": [ + " ", + " _| _|", + " _| _| ", + " _|_| ", + " _| _| ", + " _| _|", + " " + ], + "L": [ + " ", + " _| ", + " _| ", + " _| ", + " _| ", + " _|_|_|_|", + " " + ], + "M": [ + " ", + " _| _|", + " _|_| _|_|", + " _| _| _|", + " _| _|", + " _| _|", + " " + ], + "N": [ + "", + " _| _|", + " _|_| _|", + " _| _| _|", + " _| _|_|", + " _| _|", + "" + ], + "O": [ + " ", + " _|_| ", + " _| _|", + " _| _|", + " _| _|", + " _|_| ", + " " + ], + "P": [ + " ", + " _|_|_| ", + " _| _|", + " _|_|_| ", + " _| ", + " _| ", + " " + ], + "Q": [ + " ", + " _|_| ", + " _| _| ", + " _| _|_| ", + " _| _| ", + " _|_| _|", + " " + ], + "R": [ + " ", + " _|_|_| ", + " _| _|", + " _|_|_| ", + " _| _|", + " _| _|", + " " + ], + "S": [ + " ", + " _|_|_|", + " _| ", + " _|_| ", + " _|", + " _|_|_| ", + " " + ], + "T": [ + " ", + " _|_|_|_|_|", + " _| ", + " _| ", + " _| ", + " _| ", + " " + ], + "U": [ + " ", + " _| _|", + " _| _|", + " _| _|", + " _| _|", + " _|_| ", + " " + ], + "V": [ + " ", + " _| _|", + " _| _|", + " _| _|", + " _| _| ", + " _| ", + " " + ], + "W": [ + " ", + " _| _|", + " _| _|", + " _| _| _|", + " _| _| _| ", + " _| _| ", + " " + ], + "X": [ + " ", + " _| _|", + " _| _| ", + " _| ", + " _| _| ", + " _| _|", + " " + ], + "Y": [ + " ", + " _| _|", + " _| _| ", + " _| ", + " _| ", + " _| ", + " " + ], + "Z": [ + " ", + " _|_|_|_|_|", + " _| ", + " _| ", + " _| ", + " _|_|_|_|_|", + " " + ], + "0": [ + " ", + " _| ", + " _| _|", + " _| _|", + " _| _|", + " _| ", + " " + ], + "1": [ + " ", + " _|", + " _|_|", + " _|", + " _|", + " _|", + " " + ], + "2": [ + " ", + " _|_| ", + " _| _|", + " _| ", + " _| ", + " _|_|_|_|", + " " + ], + "3": [ + " ", + " _|_|_| ", + " _|", + " _|_| ", + " _|", + " _|_|_| ", + " " + ], + "4": [ + " ", + " _| _| ", + " _| _| ", + " _|_|_|_|", + " _| ", + " _| ", + " " + ], + "5": [ + " ", + " _|_|_|_|", + " _| ", + " _|_|_| ", + " _|", + " _|_|_| ", + " " + ], + "6": [ + " ", + " _|_|_|", + " _| ", + " _|_|_| ", + " _| _|", + " _|_| ", + " " + ], + "7": [ + " ", + " _|_|_|_|_|", + " _|", + " _| ", + " _| ", + " _| ", + " " + ], + "8": [ + " ", + " _|_| ", + " _| _|", + " _|_| ", + " _| _|", + " _|_| ", + " " + ], + "9": [ + " ", + " _|_| ", + " _| _|", + " _|_|_|", + " _|", + " _|_|_| ", + " " + ], + "!": [ + " ", + " _|", + " _|", + " _|", + " ", + " _|", + " " + ], + "?": [ + " ", + " _|_| ", + " _|", + " _|_| ", + " ", + " _| ", + " " + ], + ".": [ + " ", + " ", + " ", + " ", + " ", + " ", + "_|" + ], + "+": [ + " ", + " _| ", + " _| ", + " _|_|_|_|_|", + " _| ", + " _| ", + " " + ], + "-": [ + " ", + " ", + " ", + " _|_|_|_|_|", + " ", + " ", + " " + ], + "_": [ + " ", + " ", + " ", + " ", + " ", + " _|_|_|_|_|", + " " + ], + "=": [ + " ", + " ", + " _|_|_|_|_|", + " ", + " _|_|_|_|_|", + " ", + " " + ], + "@": [ + " _|_|_|_|_| ", + " _| _|", + " _| _|_|_| _|", + " _| _| _| _|", + " _| _|_|_|_| ", + " _| ", + " _|_|_|_|_|_|" + ], + "#": [ + " ", + " _| _| ", + " _|_|_|_|_|", + " _| _| ", + " _|_|_|_|_|", + " _| _| ", + " " + ], + "#": [ + " _| ", + " _|_|_|", + " _|_| ", + " _|_|", + " _|_|_|", + " _| ", + " " + ], + "%": [ + " ", + " _|_| _|", + " _|_| _| ", + " _| ", + " _| _|_|", + " _| _|_|", + " " + ], + "&": [ + " ", + " _| ", + " _| _| ", + " _|_| _|", + " _| _| ", + " _|_| _|", + " " + ], + "(": [ + " _|", + " _| ", + " _| ", + " _| ", + " _| ", + " _| ", + " _|" + ], + ")": [ + " _| ", + " _|", + " _|", + " _|", + " _|", + " _|", + " _| " + ], + "/": [ + " ", + " _|", + " _| ", + " _| ", + " _| ", + " _| ", + " " + ], + ":": [ + " ", + " ", + "_|", + " ", + "_|", + " ", + " " + ], + ";": [ + " ", + " _|", + " ", + " ", + " _|", + " _| ", + " " + ], + " ": [ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + ] + } +} \ No newline at end of file diff --git a/img/example1.png b/img/example1.png index 064f562e387d9b66b80e530458e138821063bb5e..c087019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^ z{*T?e5qVBBp3#taSCpJU%=Mm4z8l^KlMf{N#u1jH2+ogHak2kL60xjrE6cAE`%PbH zi#tN60bjoSNKI{T)4nG&1hGGFjdJlfmByqPVpnd!XBiyP;f z2|w-|bhg(|T|7pFWVF}K_dP_u5xye?k(K*PvJbqn%%}Q}FYmpyS4^yo%ZzSD{s*SA B)xiJ& diff --git a/index.js b/index.js index d70e7e32..6ef4dccc 100644 --- a/index.js +++ b/index.js @@ -1,173 +1,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('', 'g'); - var close = new RegExp('', '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 + } + }; + + +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// 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; - if( $char.length > charWidth ) { - charWidth = $char.length; + 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; + }; + + +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// 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; }; - return charWidth; -} + +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// 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 +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- + const AddChar = ( CHAR, output ) => { + CFonts.debugging.report(`Running AddChar with "${CHAR}"`, 1); + + 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; + }; //-------------------------------------------------------------------------------------------------------------------------------------------------------------- -// Main logic +// 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 //-------------------------------------------------------------------------------------------------------------------------------------------------------------- -function cfonts($SETTINGS) { + const AddLetterSpacing = ( output ) => { + CFonts.debugging.report(`Running AddLetterSpacing`, 1); + + 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; + let space = Colorize( CFonts.FONTFACE.letterspace[ index ] ) + + if( space.length === 0 && CFonts.OPTIONS.letterSpacing > 0 ) { + CFonts.debugging.report(`AddLetterSpacing: Adding space to letter spacing`, 1); + + space = ' '; + } + + output[ i ] += space.repeat( CFonts.OPTIONS.letterSpacing ); + } - //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 + 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 +// 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( FONTS.indexOf(OPTIONS.font) && OPTIONS.font !== 'console') { //getting font file + if( CFonts.FONTFACE.colors > 1 && character !== undefined ) { + for(let i = 0; i < CFonts.FONTFACE.colors; i++) { //convert all colors + let open = new RegExp(``, 'g'); + let close = new RegExp(``, 'g'); - var fontFile = __dirname + '/fonts/' + OPTIONS.font + '.json'; - $font = JSON.parse( fs.readFileSync(fontFile, 'utf8') ); + let color = CFonts.OPTIONS.colors[ i ] || 'white'; - } - else if(OPTIONS.font === 'console') { //writing in console text + character = character.replace( open, Chalk.styles[ color.toLowerCase() ].open ); + character = character.replace( close, Chalk.styles[ color.toLowerCase() ].close ); + } + } - var $write = $input.replace('|', "\n"); - $font['colors'] = 0; + return character; + }; - } - 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); - } +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// 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); - if(OPTIONS.font !== 'console') { //only render a font if it isn't the console font + let space = 0; - var $output = []; - for(var i = 0, length = $font.lines; i < length; i++) { //create first lines with buffer - $output[i] = $font.buffer[i]; + 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); } - var $charLength = 0; //use for max character per line - var $line = 0; //start with line 0 - var $letterSpacing = ""; + if( CFonts.OPTIONS.align === 'right' ) { //calculate the size for right alignment + space = WinSize.width - lineLength; - for(var i = 0, length = OPTIONS.letterSpacing; i < length; i++) { //letter spacing - $letterSpacing += colorize($font, OPTIONS, $font.letterspace[i]); + CFonts.debugging.report(`AlignText: Right lineLength: ${lineLength}, WinSize.width: ${WinSize.width}, space: ${space}`, 2); } - for(var i = 0, length = $input.length; i < length; i++) { //iterate through the message + 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(let i = lines; i < output.length; i++) { //iterate over last line + output[ i ] = space + output[ i ]; + } + } - var $char = $input.charAt(i).toUpperCase(); //only upper case is supported at this time + return output; + }; - if($charLength >= OPTIONS.maxLength || $char === "|") { //jump to next line after OPTIONS.maxLength characters or when line break is found - $charLength = 0; - $line += $font.lines; - for(var l = $line, lll = $line + $font.lines; l < lll; l++) { //create new lines with buffer - $output[l] = $font.buffer[ (l - $line) ]; +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- + 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 + } + + 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(' | ')} ]`)}` + ); + + process.exit(1); //exit program with failure code + } - for(var c = 0, l = $font.lines; c < l; c++) { //iterate over font face lines - var $character = $font.chars[ $char ][c]; + //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( $character.length < charWidth ) { - for(var w = (charWidth - $character.length) - 1; w >= 0; w--) { - $character += ' '; - }; + + 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; + } + + 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 - $output[ ($line + c) ] += $character + $letterSpacing; //save output per character + 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: { + + 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} `)}`) + ); + } + } + }, - console.log( chalk['bg' + OPTIONS.background]( $write ) ); //write out +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// 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; \ No newline at end of file +module.exports = CFonts; \ No newline at end of file diff --git a/package.json b/package.json index 9e1e1fdc..15388b02 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,18 @@ { "name": "cfonts", "description": "Sexy fonts for the console", - "version": "0.0.13", + "version": "1.0.0", "homepage": "https://github.com/dominikwilkowski/cfonts", "author": { "name": "Dominik Wilkowski", "email": "Hi@Dominik-Wilkowski.com", "url": "http://dominik-wilkowski.com/" }, + "contributors": { + "name": "Dominik Wilkowski", + "email": "Hi@Dominik-Wilkowski.com", + "url": "http://dominik-wilkowski.com/" + }, "repository": { "type": "git", "url": "git://github.com/dominikwilkowski/cfonts.git" @@ -22,21 +27,22 @@ } ], "engines": { - "node": ">= 0.8.0" + "node": ">=6.0.0" }, "scripts": { "test": "grunt test" }, "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" }, "keywords": [ "font", @@ -51,5 +57,5 @@ "bin": { "cfonts": "./bin/font.js" }, - "license": "GNU-GPL" -} + "license": "GNU-GPLv2" +} \ No newline at end of file