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.8 to 0.0.9

cfonts.sublime-project

5

Gruntfile.js

@@ -42,6 +42,11 @@ /*

test2: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -c red,magenta -m 15',
test3: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "simple"',
test4: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "simple" -c yellow -m 20',
test5: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "3d"',
test6: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "3d" -c magenta,yellow -m 7',
test7: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "console"',
test8: 'cfonts -t "a b c defghijklmnopqrstuvwxyz|0123456789|\!?.+-_=@#$%&()/:;ü" -f "console" -c blue -b white',
},

@@ -48,0 +53,0 @@

85

index.js

@@ -56,65 +56,76 @@ /*

var $input = $SETTINGS.text;
var $input = $SETTINGS.text; //text to be converted
var FONTS = '*console*block*simple*3d*'; //all supported font files
var $font = {}; //the font object
OPTIONS.background = changeCase.upperCaseFirst(OPTIONS.background); //background color case convertion
var $font = JSON.parse(fs.readFileSync(__dirname + '/fonts/' + OPTIONS.font + '.json', 'utf8')); //TODO: needs error handling
var $output = [];
for(var i = 0, length = $font.lines; i < length; i++) { //create first lines with buffer
$output[i] = $font.buffer[i];
if( FONTS.indexOf(OPTIONS.font) && OPTIONS.font !== 'console') { //getting font file
var fontFile = __dirname + '/fonts/' + OPTIONS.font + '.json';
$font = JSON.parse( fs.readFileSync(fontFile, 'utf8') );
}
else if(OPTIONS.font === 'console') { //writing in console text
var $charLength = 0; //use for max character per line
var $line = 0; //start with line 0
OPTIONS.background = changeCase.upperCaseFirst(OPTIONS.background);
var $letterSpacing = "";
var $write = $input.replace('|', "\n");
$font['colors'] = 0;
for(var i = 0, length = OPTIONS.letterSpacing; i < length; i++) { //letter spacing
$letterSpacing += colorize($font, OPTIONS, $font.letterspace[i]);
}
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 ]' + chalk.styles.green.close + "\n");
process.exit(1);
}
for(var i = 0, length = $input.length; i < length; i++) { //iterate through the message
if(OPTIONS.font !== 'console') { //only render a font if it isn't the console font
var $char = $input.charAt(i).toUpperCase(); //only upper case is supported at this time
var $output = [];
for(var i = 0, length = $font.lines; i < length; i++) { //create first lines with buffer
$output[i] = $font.buffer[i];
}
if($charLength >= OPTIONS.maxLength || $char === "|") { //jump to next line after OPTIONS.maxLength characters or when line break is found
$charLength = 0;
$line += $font.lines;
var $charLength = 0; //use for max character per line
var $line = 0; //start with line 0
var $letterSpacing = "";
for(var l = $line, lll = $line + $font.lines; l < lll; l++) { //create new lines with buffer
$output[l] = $font.buffer[ (l - $line) ];
}
for(var i = 0, length = OPTIONS.letterSpacing; i < length; i++) { //letter spacing
$letterSpacing += colorize($font, OPTIONS, $font.letterspace[i]);
}
if( $font.chars[ $char ] !== undefined) { //make sure this character exists in the font
$charLength++; //counting all printed characters
for(var c = 0, l = $font.lines; c < l; c++) { //iterate over font face lines
for(var i = 0, length = $input.length; i < length; i++) { //iterate through the message
var $character = $font.chars[ $char ][c];
var $char = $input.charAt(i).toUpperCase(); //only upper case is supported at this time
$character = colorize($font, OPTIONS, $character);
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($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');
for(var l = $line, lll = $line + $font.lines; l < lll; l++) { //create new lines with buffer
$output[l] = $font.buffer[ (l - $line) ];
}
}
// var color = OPTIONS.colors[o] || "white";
if( $font.chars[ $char ] !== undefined) { //make sure this character exists in the font
$charLength++; //counting all printed characters
// $character = $character.replace(open, chalk.styles[color.toLowerCase()].open);
// $character = $character.replace(close, chalk.styles[color.toLowerCase()].close);
// }
// }
for(var c = 0, l = $font.lines; c < l; c++) { //iterate over font face lines
$output[ ($line + c) ] += $character + $letterSpacing; //save output per character
var $character = $font.chars[ $char ][c];
$character = colorize($font, OPTIONS, $character);
$output[ ($line + c) ] += $character + $letterSpacing; //save output per character
}
}
}
var $write = $output.join("\n"); //convert to one line
}
var $write = $output.join("\n"); //convert to one line
if($font.colors <= 1) { //add text color if only one

@@ -121,0 +132,0 @@ var color = OPTIONS.colors[0] || "white";

{
"name": "cfonts",
"description": "Sexy fonts for the console",
"version": "0.0.8",
"version": "0.0.9",
"homepage": "https://github.com/dominikwilkowski/cfonts",

@@ -46,3 +46,5 @@ "author": {

"CLI",
"console"
"console",
"ascii",
"pretty"
],

@@ -49,0 +51,0 @@ "main": "index.js",

@@ -170,4 +170,6 @@ ```shell

* `block` [colors: 2]
* `simple` [colors: 1]
* `console` [colors: 1]
* `block` [colors: 2]
* `simple` [colors: 1]
* `3d` [colors: 2]

@@ -261,2 +263,3 @@ ```shell

## Release History
* 0.0.9 - added console font
* 0.0.8 - fixed bugs, docs

@@ -263,0 +266,0 @@ * 0.0.7 - changed to settings object

Sorry, the diff of this file is not supported yet

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