Git Product home page Git Product logo

figlet.js's Introduction

___________.___  ________.__          __          __
\_   _____/|   |/  _____/|  |   _____/  |_       |__| ______
 |    __)  |   /   \  ___|  | _/ __ \   __\      |  |/  ___/
 |     \   |   \    \_\  \  |_\  ___/|  |        |  |\___ \
 \___  /   |___|\______  /____/\___  >__| /\ /\__|  /____  >
     \/                \/          \/     \/ \______|    \/

Build Status NPM Downloads

This project aims to fully implement the FIGfont spec in JavaScript. It works in the browser and with Node.js. You can see it in action here: http://patorjk.com/software/taag/ (the figlet.js file was written to power that application)

Quick Start - Node.js

Install:

npm install figlet

Simple usage:

var figlet = require("figlet");

figlet("Hello World!!", function (err, data) {
  if (err) {
    console.log("Something went wrong...");
    console.dir(err);
    return;
  }
  console.log(data);
});

That should print out:

  _   _      _ _        __        __         _     _ _ _
 | | | | ___| | | ___   \ \      / /__  _ __| | __| | | |
 | |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | | |
 |  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|_|
 |_| |_|\___|_|_|\___/     \_/\_/ \___/|_|  |_|\__,_(_|_)

Basic Usage - Node.js

text

Calling the figlet object as a function is shorthand for calling the text function. This method allows you to create ASCII Art from text. It takes in 3 parameters:

  • Input Text - A string of text to turn into ASCII Art.
  • Options - Either a string indicating the font name or an options object (description below).
  • Callback - A function to execute with the generated ASCII Art.

Example:

figlet.text(
  "Boo!",
  {
    font: "Ghost",
    horizontalLayout: "default",
    verticalLayout: "default",
    width: 80,
    whitespaceBreak: true,
  },
  function (err, data) {
    if (err) {
      console.log("Something went wrong...");
      console.dir(err);
      return;
    }
    console.log(data);
  }
);

That will print out:

.-. .-')                            ,---.
\  ( OO )                           |   |
 ;-----.\  .-'),-----.  .-'),-----. |   |
 | .-.  | ( OO'  .-.  '( OO'  .-.  '|   |
 | '-' /_)/   |  | |  |/   |  | |  ||   |
 | .-. `. \_) |  |\|  |\_) |  |\|  ||  .'
 | |  \  |  \ |  | |  |  \ |  | |  |`--'
 | '--'  /   `'  '-'  '   `'  '-'  '.--.
 `------'      `-----'      `-----' '--'

textSync

This method is the synchronous version of the method above.

  • Input Text - A string of text to turn into ASCII Art.
  • Font Options - Either a string indicating the font name or an options object (description below).

Example:

console.log(
  figlet.textSync("Boo!", {
    font: "Ghost",
    horizontalLayout: "default",
    verticalLayout: "default",
    width: 80,
    whitespaceBreak: true,
  })
);

That will print out:

.-. .-')                            ,---.
\  ( OO )                           |   |
 ;-----.\  .-'),-----.  .-'),-----. |   |
 | .-.  | ( OO'  .-.  '( OO'  .-.  '|   |
 | '-' /_)/   |  | |  |/   |  | |  ||   |
 | .-. `. \_) |  |\|  |\_) |  |\|  ||  .'
 | |  \  |  \ |  | |  |  \ |  | |  |`--'
 | '--'  /   `'  '-'  '   `'  '-'  '.--.
 `------'      `-----'      `-----' '--'

Options

The options object has several parameters which you can set:

font

Type: String Default value: 'Standard'

A string value that indicates the FIGlet font to use.

horizontalLayout

Type: String Default value: 'default'

A string value that indicates the horizontal layout to use. FIGlet fonts have 5 possible values for this: "default", "full", "fitted", "controlled smushing", and "universal smushing". "default" does the kerning the way the font designer intended, "full" uses full letter spacing, "fitted" moves the letters together until they almost touch, and "controlled smushing" and "universal smushing" are common FIGlet kerning setups.

verticalLayout

Type: String Default value: 'default'

A string value that indicates the vertical layout to use. FIGlet fonts have 5 possible values for this: "default", "full", "fitted", "controlled smushing", and "universal smushing". "default" does the kerning the way the font designer intended, "full" uses full letter spacing, "fitted" moves the letters together until they almost touch, and "controlled smushing" and "universal smushing" are common FIGlet kerning setups.

width

Type: Number Default value: undefined

This option allows you to limit the width of the output. For example, if you want your output to be a max of 80 characters wide, you would set this option to 80. Example

whitespaceBreak

Type: Boolean Default value: false

This option works in conjunction with "width". If this option is set to true, then the library will attempt to break text up on whitespace when limiting the width. Example

Understanding Kerning

The 2 layout options allow you to override a font's default "kerning". Below you can see how this effects the text. The string "Kerning" was printed using the "Standard" font with horizontal layouts of "default", "fitted" and then "full".

  _  __               _
 | |/ /___ _ __ _ __ (_)_ __   __ _
 | ' // _ \ '__| '_ \| | '_ \ / _` |
 | . \  __/ |  | | | | | | | | (_| |
 |_|\_\___|_|  |_| |_|_|_| |_|\__, |
                              |___/
  _  __                   _
 | |/ / ___  _ __  _ __  (_) _ __    __ _
 | ' / / _ \| '__|| '_ \ | || '_ \  / _` |
 | . \|  __/| |   | | | || || | | || (_| |
 |_|\_\\___||_|   |_| |_||_||_| |_| \__, |
                                    |___/
  _  __                        _
 | |/ /   ___   _ __   _ __   (_)  _ __     __ _
 | ' /   / _ \ | '__| | '_ \  | | | '_ \   / _` |
 | . \  |  __/ | |    | | | | | | | | | | | (_| |
 |_|\_\  \___| |_|    |_| |_| |_| |_| |_|  \__, |
                                           |___/

In most cases you'll either use the default setting or the "fitted" setting. Most fonts don't support vertical kerning, but a hand full of them do (like the "Standard" font).

metadata

The metadata function allows you to retrieve a font's default options and header comment. Example usage:

figlet.metadata("Standard", function (err, options, headerComment) {
  if (err) {
    console.log("something went wrong...");
    console.dir(err);
    return;
  }
  console.dir(options);
  console.log(headerComment);
});

fonts

The fonts function allows you to get a list of all of the available fonts. Example usage:

figlet.fonts(function (err, fonts) {
  if (err) {
    console.log("something went wrong...");
    console.dir(err);
    return;
  }
  console.dir(fonts);
});

fontsSync

The synchronous version of the fonts method

console.log(figlet.fontsSync());

parseFont

Allows you to use a font from another source.

const fs = require("fs");
const path = require("path");

let data = fs.readFileSync(path.join(__dirname, "myfont.flf"), "utf8");
figlet.parseFont("myfont", data);
console.log(figlet.textSync("myfont!", "myfont"));

Getting Started - Webpack / React

Webpack/React usage will be very similar to what's talked about in the "Getting Started - The Browser" section. The main difference is that you import fonts via the importable-fonts folder. Example:

import figlet from "figlet";
import standard from "figlet/importable-fonts/Standard.js";

figlet.parseFont("Standard", standard);

figlet.text(
  "test",
  {
    font: "Standard",
  },
  function (err, data) {
    console.log(data);
  }
);

Getting Started - The Browser

The browser API is the same as the Node API with the exception of the "fonts" method not being available. The browser version also requires fetch API (or a shim) for its loadFont function.

Example usage:

<script
  type="text/javascript"
  src="//cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"
></script>
<script type="text/javascript" src="figlet.js"></script>

<script>
  figlet(inputText, "Standard", function (err, text) {
    if (err) {
      console.log("something went wrong...");
      console.dir(err);
      return;
    }
    console.log(text);
  });
</script>

textSync

The browser API supports synchronous mode so long as fonts used are preloaded.

Example:

figlet.defaults({ fontPath: "assets/fonts" });

figlet.preloadFonts(["Standard", "Ghost"], ready);

function ready() {
  console.log(figlet.textSync("ASCII"));
  console.log(figlet.textSync("Art", "Ghost"));
}

That will print out:

     _     ____    ____  ___  ___
    / \   / ___|  / ___||_ _||_ _|
   / _ \  \___ \ | |     | |  | |
  / ___ \  ___) || |___  | |  | |
 /_/   \_\|____/  \____||___||___|

   ('-.     _  .-')   .-') _
  ( OO ).-.( \( -O ) (  OO) )
  / . --. / ,------. /     '._
  | \-.  \  |   /`. '|'--...__)
.-'-'  |  | |  /  | |'--.  .--'
 \| |_.'  | |  |_.' |   |  |
  |  .-.  | |  .  '.'   |  |
  |  | |  | |  |\  \    |  |
  `--' `--' `--' '--'   `--'

See the examples folder for a more robust front-end example.

Getting Started - Command Line

To use figlet.js on the command line, install figlet-cli:

npm install -g figlet-cli

And then you should be able run from the command line. Example:

figlet -f "Dancing Font" "Hi"

For more info see the figlet-cli.

Contributors

Thanks goes to these people: (emoji key)

patorjk
patorjk

πŸ’» πŸ“– ⚠️ πŸš‡ πŸ’‘
Jakub T. Jankiewicz
Jakub T. Jankiewicz

πŸ’» πŸ“– ⚠️
Michael J. Ryan
Michael J. Ryan

πŸ’» πŸ“–
Manuel Ernst
Manuel Ernst

πŸ’» πŸ“–
Eirik Stanghelle Morland
Eirik Stanghelle Morland

πŸš‡
George
George

πŸ’‘ πŸ“–
Adnan M.Sagar, PhD
Adnan M.Sagar, PhD

πŸ’» πŸ“–
Abhishek Choudhary
Abhishek Choudhary

πŸ“–
Jason
Jason

πŸ’» πŸ“–
mbodomi
mbodomi

🎨 πŸ’»
Orkhan Huseynli
Orkhan Huseynli

πŸ’»
Domenic Melcher
Domenic Melcher

πŸ“–
a-raccoon
a-raccoon

πŸ“–
Peter deHaan
Peter deHaan

πŸ“–
Ionică Bizău (Johnny B.)
Ionică Bizău (Johnny B.)

πŸ“–
t1st3
t1st3

πŸ’»
Tim Hudson
Tim Hudson

πŸ’»

Release History

  • 2023.04.08 v1.6.0 Added npx support (ex: npx figlet test).
  • 2021.08.11 v1.5.2 Minor bug fixes.
  • 2020.07.12 v1.5.1 Fixed with vertical smushing, updated lodash version.
  • 2020.07.12 v1.5.0 Added width and whitespaceBreak options.
  • 2020.04.26 v1.4.0 Removed jQuery from preloader and examples.
  • 2020.02.23 v1.3.0 Added the "ANSI Regular" font and updated the README with info on how to use with Webpack.
  • 2018.03.26 v1.2.1 parseFont works in node for adding fonts manually
  • 2016.09.27 v1.2.0 jQuery replaced with fetch API / polyfill.
  • 2016.04.28 v1.1.2 textSync now works in the browser with font pre-loading.
  • 2014.08.15 v1.1.0 Sync functions added.
  • 2014.07.31 v1.0.1 Bug fixes.
  • 2013.12.28 v1.0.7 README update and minor tweaks.
  • 2013.01.02 v1.0.8 Added tests and command line info.

figlet.js's People

Contributors

patorjk avatar allcontributors[bot] avatar dependabot[bot] avatar jcubic avatar tracker1 avatar seriousmanual avatar eiriksm avatar websemantics avatar horhik avatar jasongoemaat avatar mbodomi avatar shreemaan-abhishek avatar ionicabizau avatar letsmelon avatar orkhan-huseyn avatar pdehaan avatar t1st3 avatar timhudson avatar

Stargazers

Carter Li avatar Majokeiko avatar rc avatar JasonSung avatar Achmad F.  Ibrahim avatar StoneRen avatar Dmitry Vorotilin avatar Sherry_AB avatar  avatar Qazxxx avatar  avatar Fernando Zhu avatar Ruggery Iury avatar Michael avatar ζŒ‡ι—΄ηš„θ―—ζ„ avatar Md Samin Yasar Islam avatar  avatar Chadin Chaipornpisuth avatar Shayan avatar  avatar He Linming avatar Yunus KoΓ§yiğit avatar ColorfulDream avatar Kha'Zix avatar Mike Powers avatar  avatar Lu-Jiejie avatar FeelinLucky avatar panghu avatar MrDiro avatar b0rn-b0rked avatar  avatar Josh Medeski avatar Khashayar avatar Chao avatar PastaGringo avatar ζ‡’ζˆι“ avatar PeggyPro avatar Amnot avatar Amirhossein Bidokhti avatar Silvestro Ranucci avatar Leonardo Lopes avatar Windson avatar Jems avatar  avatar Tobias Karentius Kromann Dahl avatar Ritchie Zhu avatar Hitesh Kumar avatar e52V avatar  avatar SahilGomes avatar mathmakgakpak avatar Azis Ramadhan avatar Teerapat Prommarak avatar  avatar  avatar Dan| avatar  avatar θ₯Ώη“œηˆΈζ―” avatar Dalton Menezes avatar Henry MogollΓ³n avatar  avatar  avatar Derrick Roach avatar ⓐⓒ Joel β“’ avatar Paul Melero avatar Hoang Tran avatar Jinseok Eo avatar Axmin Shrestha avatar Ben avatar Raja Rakotonirina avatar  avatar gentlecoder avatar Oumar Barry avatar Nikola Rusakov avatar Jonny Gamba avatar reemo avatar chenweiyi avatar Stuart Saunders avatar piapot avatar bfhyqy avatar Nick avatar Romain RICHARD avatar ι˜Ώε†° avatar YieldRay avatar  avatar chenglu avatar Vladislav Petrov avatar JoΓ£o VΓ­ctor avatar  avatar Amresh Prasad Sinha avatar Theo avatar Ben Peachey avatar Jimmy avatar eivmosn avatar  avatar Mateus V. Farias avatar anhnhoktvn avatar Robby avatar  avatar

Watchers

Robert Gerlach avatar Daniel Grillo avatar  avatar Will Pracht avatar timelyportfolio avatar James Cloos avatar hunslater avatar Evan Zhang avatar echo avatar Michael Anthony avatar  avatar Michael Paulukonis avatar Ten avatar Vini Martins avatar VrWorking avatar Nine Machines avatar _C1f3R_ avatar ./HEX404 avatar  avatar

figlet.js's Issues

Webpack & TypeScript support

Hello there, first of all, thanks for this awesome package which enhances all our CLI tool πŸ‘

Problem Statement

We would like to develop a more robust CLI tool using Webpack & TypeScript. Everything is setup and works properly but I'm running into some errors with figlet integration.

Context

Here is my setup for the project, I will create a boilerplate if needed on Github.
But right now, I can share the webpack.config.js:

const path = require('path');

module.exports = {
  mode: 'development',
  entry: './src/index.ts',
  target: 'node',
  stats: {
    warnings: false // /!\ nunjucks as broken import, so webpack log warnings, disabling them for now...
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js']
  },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    libraryTarget: 'commonjs'
  }
};

and the tsconfig.json

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "outDir": "./dist",
    "strict": true,
    "baseUrl": "./src/",
    "typeRoots": ["node_modules/@types"],
    "types": ["node"],
    "esModuleInterop": true,
    "inlineSourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "resolveJsonModule": true,
    "preserveSymlinks": true
  }
}

But when I want to use figlet there is some errors.

First, with a simple implementation:

import figlet from 'figlet';

console.log(chalk.greenBright(figlet.textSync('plop')));

This will throw an error because webpack doesn't achieve to resolve the fonts folder.

(node:12876) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/fonts/Standard.flf'
    at Object.openSync (fs.js:440:3)
    at Object.readFileSync (fs.js:342:35)
    at Function.figlet.loadFontSync (webpack:///./node_modules/figlet/lib/node-figlet.js?:48:23)
    at Object.me.textSync (webpack:///./node_modules/figlet/lib/figlet.js?:732:43)
    at main (webpack:///./src/index.ts?:27:52)
    at Object.eval (webpack:///./src/index.ts?:66:1)
    at eval (webpack:///./src/index.ts?:68:30)

I saw issues about this: #46 & #50 but the node: { __dirname: false } just don't work (or you have to copy the fonts folder at root of your project) & figlet.parseFont has no typing - see DefinitelyTyped/DefinitelyTyped#38318

import figlet from "figlet";
import banner3 from "figlet/importable-fonts/Banner3";

figlet.parseFont("Banner3", banner3);

Add to this, the solution with parseFont is the best I think but you have to declare all importable-fonts in the typing too or you will get this error: If the 'figlet' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/figlet.ts(7016)

import figlet from "figlet";
import banner3 from "figlet/importable-fonts/Banner3";

figlet.parseFont("Banner3", banner3);

Possible Solution

I think we just need to update the typing of figlet on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/figlet/index.d.ts

  • add parseFont
  • expose importable-fonts as a module

I'm not an expert on module typing with TypeScript that's why I create an issue & not a pull request in order to discuss the best way to create the typing.

Thanks for help πŸ‘

Font name problem

I just spend a few days, debuging problems with rpm build in my project. I discover, that package was unable to build because of ' character in fonts name (node_modules/figlet/fonts/Patorjk's?Cheese.flf), it's causing some strange errors in building package.
Is there any possibility to change this font name to "PatorjksCheese.flf" or similar?

Fonts causing problems:

  • node_modules/figlet/fonts/Patorjk's?Cheese.flf
  • node_modules/figlet/importable-fonts/Patorjk's?Cheese.js

can't find font file

os: macOs 10.15.3
node: 8.9.4
Error: ENOENT: no such file or directory, open '/fonts/Standard.flf'
change another font type also get this error message

Unexpected token u

I made little script to get a overview over all fonts that are possible:

var fs = require('fs');

var figlet = require('figlet');

fs.readdirSync('./node_modules/figlet/fonts').forEach(function(font) {
    if (font.indexOf('.flf') == -1) return;

    figlet.text('abc ABC ...', {
        font: font.split('.')[0]
    }, function(err, data) {
        if (err) return console.log('Something went wrong...');

        console.log(font);
        console.log(data);
    });
});

when running figlet breaks on several of the included fonts with the following error:

undefined:1
undefined
^
SyntaxError: Unexpected token u
    at Object.parse (native)
    at D:\programming\strichliste\node_modules\figlet\lib\figlet.js:716:31
    at D:\programming\strichliste\node_modules\figlet\lib\node-figlet.js:24:13
    at Function.me.parseFont (D:\programming\strichliste\node_modules\figlet\lib\figlet.js:899:21)
    at D:\programming\strichliste\node_modules\figlet\lib\node-figlet.js:23:16
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)

Preview

Hello,

It could be great to have a preview of all fonts.

For the moment I do this command:

figlet -l|xargs -I FONT sh -c 'echo "FONT:" && figlet -f "FONT" "Imhotep" && echo "-------------------------"'

which works great but it could be built-in.

Cannot read property 'reduce' of undefined

Just got this error when using a custom font in NodeJS. Even the example 'Ghost' font doesn't work. And preloadFonts use fetch so it's for browser only.

I have code like this:

const { promisify } = require('util');
const figlet = require('figlet');
const render = promisify(figlet.text);

const config = {
    font: 'Colossal',
    width: 80,
    whitespaceBreak: true
};

module.exports = async () => {
    const text = 'Jakub T. Jankiewicz';
    return {
        wrap: await render(text, {...config, width: 12}),
        big: await  render(text, config)
    };
};

The issue with probably with line wrapping.

small slant.flf does not work in Ubuntu

Running this on Ubuntu:

const figlet = require('figlet');

console.log(
  chalk.keyword('orange')(
    figlet.textSync('scooter-cli', {font: 'small slant', horizontalLayout: 'full', verticalLayout: 'controlled smushing'})
  ) + 'v' + chalk.white.bold(pkg.version) + '\n\n\n'
);

...results in the following error:

Error: ENOENT: no such file or directory, open '/home/ubuntu/dev/scooter/cli/node_modules/figlet/fonts/small slant.flf'

Not critical but thought I would report it.

How to break lines?

https://github.com/cmatsuoka/figlet has a option :
-t terminal -- FIGlet asks your terminal how wide it is, and uses
this to determine when to break lines. Normally, FIGlet assumes
80 columns so that people with wide terminals won't annoy the
people they e-mail FIGlet output to.

How do I use this?

Using importable-fonts give illegible skewed text results

Using this in my node server gives the skewed output

import standard from "figlet/importable-fonts/Standard.js";
figlet.parseFont("Standard", standard);
figlet.text(
  "Anobisssss",
  {
    font: "Standard"
  },
  function(err, data) {
    console.log(data);
  }
);

Screenshot 2019-09-01 at 11 12 38

While specifying without parseFont works fine, figlet("Anobis", { font: "Red Phoenix" }, (...))

Screenshot 2019-09-01 at 11 16 07

Add "ANSI Regular" font to the font directory

Hi,
First, congrats for this great package, used by many IDE extensions!

In many of those extensions (eg. Banner Comments for VSCode), the default font is "ANSI Shadow".
The problem with this font is that it is not readable in the minimap on the right side.

The "ANSI Regular" solves the readability issue, unfortunately it is not included by default in your package.

The "ANSI Regular" can be found in https://github.com/xero/figlet-fonts or https://github.com/miguelmota/figlet-ansi-regular-font

It would be wonderful if you could add it and consequently make it available in all those extensions that depend on your package.
Thank you!

how to use fig let generated words

i successfully generated the words in cmd i wanted but i don't know how to use these in html comments of my page now i build them in sublime and copy them We should make some GUI interface for ease

Error

Code : return next(err)

Error message : next is not function

Migrating to ES6

I would love to contribute to this fantastic module and I think migrating to ES6 would minimize the codebase. Can I go ahead ?

TypeError: Cannot read properties of undefined (reading 'reduce')

I found the same issue(#73), but it is closed.

I examined the code, then found a few things.

  1. In generateFigTextLines, nextFigChars.chars becomes undefined; It is because of breakWord.
  2. When nextFigChars.chars is undefined, joinFigArray throws an Error.

The first thing is a more significant problem.
The code looks like this:

function breakWord(figChars, len, opts) {
        var result = {};
        for (var i = figChars.length; --i;) {
            var w = joinFigArray(figChars.slice(0, i), len, opts);
            if (figLinesWidth(w) <= opts.width) {
                result.outputFigText = w;
                if (i < figChars.length) {
                    result.chars = figChars.slice(i);
                } else {
                    result.chars = [];
                }
                break;
            }
        }
        return result;
    }

The return value, result, is sometimes not fully initialized.

No File or Directory

Everything runs fine on MacOSX, but i moved my project to run a on Cent OS, and now I get this error. The rest of my project runs fine as well.

node server.js

{ Error: ENOENT: no such file or directory, open '/home/mitsuha/node_modules/figlet/lib/../fonts/colossal.flf'
    at Error (native)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/mitsuha/node_modules/figlet/lib/../fonts/colossal.flf' }

I can confirm the font exist, but not in that directory. They are in node_modules/figlet/fonts

Here is my code...

const figlet = require('figlet');

figlet('Mitsuha', {
            font: 'colossal',
        },
        (err, data) => {
            if (err) return console.log(err);
            console.log(data);
        });

Figlet.js does not work with Browserify

When I include Figlet.js to the front-end using browserify, the whole thing stops working because of the fs module.

I tried to avoid calling methods that use fs mainly by preloading the fonts using preloadFonts method.

However, when using text or textSync methods the loadFontSync method gets triggered in node.js mode which does not check for already loaded fonts as in the case of browser mode

I created a stop-gap package that solves the problem initially,
https://github.com/websemantics/figlet-browserify but it would be nice to make necessary changes to the library to make it work in the browser regardless of the package manager,

Cannot find module figlet

echo "lol" | figlet
node:internal/modules/cjs/loader:1063
  throw err;
  ^

Error: Cannot find module 'figlet'
Require stack:
- C:\Users\alex\AppData\Roaming\npm\node_modules\figlet-cli\bin\figlet
    at Module._resolveFilename (node:internal/modules/cjs/loader:1060:15)
    at Module._load (node:internal/modules/cjs/loader:905:27)
    at Module.require (node:internal/modules/cjs/loader:1127:19)
    at require (node:internal/modules/helpers:112:18)
    at Object.<anonymous> (C:\Users\alex\AppData\Roaming\npm\node_modules\figlet-cli\bin\figlet:7:14)
    at Module._compile (node:internal/modules/cjs/loader:1246:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1300:10)
    at Module.load (node:internal/modules/cjs/loader:1103:32)
    at Module._load (node:internal/modules/cjs/loader:942:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\alex\\AppData\\Roaming\\npm\\node_modules\\figlet-cli\\bin\\figlet'
  ]
}

Node.js v19.5.0

Error with example code?

I installed Figlet and inserted the sample code into my code via Copy & Paste.

var figlet = require('figlet');
 
figlet('Hello World!!', function(err, data) {
    if (err) {
        console.log('Something went wrong...');
        console.dir(err);
        return;
    }
    console.log(data)
});

The following message appears in the browser's console:

Something went wrong...

Error: FIGlet header contains invalid values.
    at Function.me.parseFont (http://localhost:1234/main.c138d377.js:1148:13)
    at http://localhost:1234/main.c138d377.js:1265:21

Slant front weird rendering

I've just got weird rendering of text "Terminal Chess" in Slant font when wrapping.

  ______                    _             __
 /_  __/__  _________ ___  (_)___  ____ _/ /
  / / / _ \/ ___/ __ `__ \/ / __ \/ __ `/ / 
 / / /  __/ /  / / / / / / / / / / /_/ / /  
/_/__\\\\\\/  /_/ /_/ /_/_/_/ /_/\__,_/_/   
  / ____/ /_  ___  __________               
 / /   / __ \/ _ \/ ___/ ___/               
/ /___/ / / /  __(__  |__  )                
\____/_/ /_/\___/____/____/                 

See the "e" letter. Reproducing demo https://codepen.io/jcubic/pen/JjGxvMY?editors=0010

Reversed text bug for ivrit font

The ivrit font has a weird behaviour. The text is printed as reversed text.

console.log(figlet.textSync('Logged In', {
  font: 'ivrit'
}));
        ___       _                        _
  _ __ |_ _|   __| | ___  __ _  __ _  ___ | |
 | '_ \ | |   / _` |/ _ \/ _` |/ _` |/ _ \| |
 | | | || |  | (_| |  __/ (_| | (_| | (_) | |___
 |_| |_|___|  \__,_|\___|\__, |\__, |\___/|_____|
                         |___/ |___/

Unknown error

Im getting an "UNKNOWN" errorno -4094
Code:

    figlet("Test", function(err, data) {
        if (err) {
            console.log(err);
            return;
        }
        message.channel.send('```' + data + '```')
    })```

Error:
`{ [Error: UNKNOWN: unknown error, open '//../fonts/Standard.flf']
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'open',
  path: '//../fonts/Standard.flf' }
`

Doesn't work with react

My App.tsx's constructor looks like the following in my react app

constructor() {
    super();
    figlet('Sezzle', 'Standard', function(err, data) {
      if (err) {
          console.log('Something went wrong...');
          console.dir(err);
          return;
      }
      console.log(data);
    });
  }

But the output in the console is

Error: FIGlet header contains invalid values.
    at Function.me.parseFont (eval at ./node_modules/figlet/lib/figlet.js (http://localhost:3000/main.js:969:1), <anonymous>:842:19)
    at eval (eval at ./node_modules/figlet/lib/figlet.js (http://localhost:3000/main.js:969:1), <anonymous>:951:31)
    at <anonymous>

I logged in the node module's parseFont function and I see that the headerData looks like this:
["<!doctype", "html>"] which is why the opts in the function is not being filled.

Please help.

Bloody font renders text backwards in original figlet

This is quite possibly a figlet bug, not a problem with the converted font, but wanted to report here to check...

I've been using the 10 converted ANSI fonts with the original figlet. Most of them work fine, but Bloody renders text right-to-left. Sample output from showfigfonts:

Bloody :
                            β–“β–ˆβ–ˆ   β–ˆβ–ˆβ–“β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„  β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆβ–“     β–„β–„β–„β–„
                             β–’β–ˆβ–ˆ  β–ˆβ–ˆβ–’β–’β–ˆβ–ˆβ–€ β–ˆβ–ˆβ–Œβ–’β–ˆβ–ˆβ–’  β–ˆβ–ˆβ–’β–’β–ˆβ–ˆβ–’  β–ˆβ–ˆβ–’β–“β–ˆβ–ˆβ–’    β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„
                              β–’β–ˆβ–ˆ β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆ   β–ˆβ–Œβ–’β–ˆβ–ˆβ–‘  β–ˆβ–ˆβ–’β–’β–ˆβ–ˆβ–‘  β–ˆβ–ˆβ–’β–’β–ˆβ–ˆβ–‘    β–’β–ˆβ–ˆβ–’ β–„β–ˆβ–ˆ
                              β–‘ β–β–ˆβ–ˆβ–“β–‘β–‘β–“β–ˆβ–„   β–Œβ–’β–ˆβ–ˆ   β–ˆβ–ˆβ–‘β–’β–ˆβ–ˆ   β–ˆβ–ˆβ–‘β–’β–ˆβ–ˆβ–‘    β–’β–ˆβ–ˆβ–‘β–ˆβ–€
                              β–‘ β–ˆβ–ˆβ–’β–“β–‘β–‘β–’β–ˆβ–ˆβ–ˆβ–ˆβ–“ β–‘ β–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘ β–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–‘β–“β–ˆ  β–€β–ˆβ–“
                               β–ˆβ–ˆβ–’β–’β–’  β–’β–’β–“  β–’ β–‘ β–’β–‘β–’β–‘β–’β–‘ β–‘ β–’β–‘β–’β–‘β–’β–‘ β–‘ β–’β–‘β–“  β–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–€β–’
                             β–“β–ˆβ–ˆ β–‘β–’β–‘  β–‘ β–’  β–’   β–‘ β–’ β–’β–‘   β–‘ β–’ β–’β–‘ β–‘ β–‘ β–’  β–‘β–’β–‘β–’   β–‘
                             β–’ β–’ β–‘β–‘   β–‘ β–‘  β–‘ β–‘ β–‘ β–‘ β–’  β–‘ β–‘ β–‘ β–’    β–‘ β–‘    β–‘    β–‘
                             β–‘ β–‘        β–‘        β–‘ β–‘      β–‘ β–‘      β–‘  β–‘ β–‘
                             β–‘ β–‘      β–‘                                      β–‘

Can blank lines be preserved?

const figlet = require("figlet")

const text = `


hello



world


`;

console.log(figlet.textSync(text));

yields the following output:

  _          _ _             
 | |__   ___| | | ___        
 | '_ \ / _ \ | |/ _ \       
 | | | |  __/ | | (_) |      
 |_| |_|\___|_|_|\___/     _ 
 __      _____  _ __| | __| |
 \ \ /\ / / _ \| '__| |/ _` |
  \ V  V / (_) | |  | | (_| |
   \_/\_/ \___/|_|  |_|\__,_|

So is there a way the blanks lines can be preserved?

Examples directory of the repository is part of the NPM package

Hi there,

Thanks for the library, ASCII art ftw πŸ˜„

That being said, my vulnerability check reported a problem with figlet because it found an old version of jQuery that has been flagged for security issues. I was surprised at first because I thought that the library has no dependency on jQuery but after inspecting the node_modules/figlet directory I noticed that the folder examples that contain jQuery is part of the NPM package.

Is there any plan to remove the examples folder from the distributed package?

image

Ansi Figlet fonts not rendering properly in browser

Hi, thank you very much for this!

I'm testing the Ansi Figlet fonts (for example "Electronic") in the browser, if I print them in the console they appear good but within a <pre> block they are not properly rendered.

Is there any special css rules to apply for these cases?

screen shot 2014-11-23 at 9 25 12 pm

Break long sentences on multiple lines

This is more a css related issue but specifically for this project.
I insert the resulting computed ascii in a pre tag and the problem comes when I have long sentences that I'd like to break on multiple lines.
I've tried with this css as suggested here

pre {
  white-space: -moz-pre-wrap /* Mozilla, supported since 1999 */
  white-space: -pre-wrap /* Opera */
  white-space: -o-pre-wrap /* Opera */
  white-space: pre-wrap /* CSS3 - Text module (Candidate Recommendation) http://www.w3.org/TR/css3-text/#white-space */
  word-wrap: break-word /* IE 5.5+ */
}

but this breaks the formatting. I have to revert to pre { white-space: pre} or things won't work.

I was wondering if anyone has already encountered (and possibly solved) this issue.

Ogre font is missing

Getting following error when I change the font to ogre.

var figlet = require('figlet');

figlet.text('hello world', {
    font: 'ogre',
    horizontalLayout: 'default',
    verticalLayout: 'default'
}, function(err, data) {
    if (err) {
        console.log('Something went wrong...');
        console.dir(err);
        return;
    }
    console.log(data);
});

Error -

{ Error: ENOENT: no such file or directory, open '/home/thilina/node_modules/figlet/lib/../fonts/ogre.flf'
    at Error (native)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/thilina/node_modules/figlet/lib/../fonts/ogre.flf' }

I'm using Fedora 26 with; node v6.11.2.

bloody font include CYRILLIC symbols

Hi. Is it possible to enable support for Cyrillic in BLOODY font, me in my project really need it. I would be very grateful for the help, thank you in advance.

Readability issues in README.md

There are minor issues (grammatical) in the README.md file.
Example: 1, 2. There are more I guess πŸ€”

It is understandable that such issues are intuitive for native English speakers. But non-native speakers might have a wrong assumption while reading them and have trouble understaing.

Possibility to add one empty line at the top/beginning

When using the figlet on Gitlab runners the text get's a little messed up since always at the beginning of the line there is worker identifier ([0-0]) in that particular case. It would be nice if you can place empty line at the beginning/top of the figlet so this wouldn't happen.

This is how it looks like:

image

Problem with code that pollute array prototype

I use filget.js with ROT.js library (for rouge like games) and it modify Array prototype and it break figlet. This can be easy fixed. The problem is this line:

for(var i in fonts){
   me.parseFont(fonts[i], fontData[i]);
}

the loop should use hasOwnProperty to filter out stuff from prototype.

Option to disable prefix padding?

It seems that figlet is always adding padding to the beginning of a rendered word. Using Larry 3D, this is the output for "node-framework":

                          __                      ___                                                              __
                         /\ \                   /'___\                                                            /\ \
          ___     ___    \_\ \     __          /\ \__/  _ __    __      ___ ___      __   __  __  __    ___   _ __\ \ \/'\
        /' _ `\  / __`\  /'_` \  /'__`\ _______\ \ ,__\/\`'__\/'__`\  /' __` __`\  /'__`\/\ \/\ \/\ \  / __`\/\`'__\ \ , <
        /\ \/\ \/\ \L\ \/\ \L\ \/\  __//\______\\ \ \_/\ \ \//\ \L\.\_/\ \/\ \/\ \/\  __/\ \ \_/ \_/ \/\ \L\ \ \ \/ \ \ \\`\
        \ \_\ \_\ \____/\ \___,_\ \____\/______/ \ \_\  \ \_\\ \__/.\_\ \_\ \_\ \_\ \____\\ \___x___/'\ \____/\ \_\  \ \_\\_\
         \/_/\/_/\/___/  \/__,_ /\/____/          \/_/   \/_/ \/__/\/_/\/_/\/_/\/_/\/____/ \/__//__/   \/___/  \/_/   \/_/\/_/

Why is there a poopton of padding at the start of each line, and how can we turn that off?

Font file for Calvin is missing...?

I'm using figlet to draw a success banner in a prepublish hook,
I've been using it happily for quite a while, where the success banner choses a font in random - but I have encountered today the following error:

ERROR <proj>-compiler - processing ended { [Error: ENOENT, open '/opt/jenkins/jobs/<project>/workspace/node_modules/<utility-package>node_modules/figlet/lib/../fonts/Calvin.flf']
  errno: 34,
  code: 'ENOENT',
  path: '/opt/jenkins/jobs/<project>/workspace/node_modules/<utility-pkg>/node_modules/figlet/lib/../fonts/Calvin.flf' }
Error: ENOENT, open '/opt/jenkins/jobs/<project>/workspace/node_modules/<utility-pkg>/node_modules/figlet/lib/../fonts/Calvin.flf'
FATAL osg-rules-compiler:CLI - compilation complete with errors
npm ERR! weird error 1
npm ERR! not ok code 0

I could note that the font file for Calvin is missing on the disk...
I can see there Calvin S though...

maybe something is lost with names?

[taag] More 'Test All' options; filtering.

I would like to propose a couple additions to the taag site:

Allow the Test All button to only print fonts from specific font categories.

Allow the Test All button to only print fonts that are of a specified number of lines; equal to, greater than, less than. Each font declares how many lines (tall) it is, plus one, in its headers.

synchronous version

hi,
have you ever thought of making an synchronous way of calling the text function?

could be something like:

console.log(figlet.textSync('Boo!', { font:'Ghost'}));

which acts identically to the async version but returns the created text.

Missing parseFont typescript definition

I got an error from typescript when using parseFont with the font from importable-fonts, following the instruction from #32:

import figlet from "figlet";
import banner3 from "figlet/importable-fonts/Banner3";

figlet.parseFont("Banner3", banner3);

On the 4th line: Property 'parseFont' does not exist on type 'typeof figlet'.

More information:

os: Windows 10
node: 10.12.0
figlet: ^1.2.4
typescript: 3.5.2

Explain character padding: Blank line, left/right whitespace

I'm curious if there are specific rhymes or reason for blank lines in some font character sets, or why some have whitepace padding on the right side or left and right side of some or all characters. Looking for the extended history explanations of how the renderers used to and currently work differently or the same, and what is ideal. I really would like to take out the blank line paddings, where every character has an extra blank line, ie, a 2 line font uses 3.

TTF -> FLF?

Hi,

Thanks for making this project!

Feel free to close as a non-issue, but: have you ever come across any online or command-line tools to convert ttf/otf fonts to flf files, maybe using some parameters for chars used / dithering / rendering / spacing?

Stick Letters font has problem with Z

(I don't know if this is only a problem in the web service, since I have only tested it there)

Using the Stick Letters font, the output is partially corrupted when typing z or Z.

Steps to reproduce:
http://patorjk.com/software/taag/#p=display&v=0&c=bash&f=Stick%20Letters&t=Customization

Expected output:

#   __        __  ___  __          __      ___    __       
#  /  ` |  | /__`  |  /  \  |\/| |  /  /\   |  | /  \ |\ | 
#  \__, \__/ .__/  |  \__/  |  | | /_ /~~\  |  | \__/ | \| 
#                                                          

Actual output:

#   __        __  ___  __          __      ___    __       
#  /  ` |  | /__`  |  /  \  |\/| |  / @ /\   |  | /  \ |\ | 
#  \__, \__/ .__/  |  \__/  |  | | /_ @/~~\  |  | \__/ | \| 
#                                     @@                     

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.