CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-figlet

Creates ASCII Art from text with a full implementation of the FIGfont specification

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

FIGlet

FIGlet creates ASCII art from text using a comprehensive implementation of the FIGfont specification. It provides both synchronous and asynchronous APIs for text conversion, supports extensive font management with 400+ built-in fonts, and offers advanced layout control with horizontal and vertical fitting rules for precise output formatting.

Package Information

  • Package Name: figlet
  • Package Type: npm
  • Language: JavaScript (ES5+ compatible)
  • Installation: npm install figlet

Core Imports

const figlet = require("figlet");

For ES modules:

import figlet from "figlet";

Individual function imports:

const { text, textSync, loadFont, fonts } = require("figlet");

Basic Usage

const figlet = require("figlet");

// Simple async usage with callback
figlet("Hello World", function(err, data) {
  if (err) {
    console.log("Error:", err);
    return;
  }
  console.log(data);
});

// Promise-based usage
figlet.text("Hello World", { font: "Ghost" })
  .then(data => console.log(data))
  .catch(err => console.error(err));

// Synchronous usage (Node.js only)
try {
  const result = figlet.textSync("Hello World", { font: "Big" });
  console.log(result);
} catch (err) {
  console.error(err);
}

Architecture

FIGlet is built around several key components:

  • Text Generation Engine: Core rendering system with smushing algorithms and layout controls
  • Font Management System: Font loading, parsing, and caching for both browser and Node.js environments
  • Configuration System: Comprehensive options for horizontal/vertical layout, text wrapping, and display formatting
  • Cross-Platform Support: Unified API with platform-specific optimizations for Node.js (filesystem) and browser (fetch API)

Capabilities

Text Generation

Core text-to-ASCII conversion functionality supporting both synchronous and asynchronous operations with extensive font and layout options.

// Main function (alias for figlet.text)
function figlet(text, options, callback);

// Async text generation
function text(text, options, callback);

// Sync text generation (Node.js only)  
function textSync(text, options);

Text Generation

Font Management

Font loading, listing, and management system supporting both browser and Node.js environments with comprehensive font discovery.

// Load font asynchronously
function loadFont(name, callback);

// Load font synchronously (Node.js only)
function loadFontSync(name);

// Preload multiple fonts
function preloadFonts(fonts, callback);

// List available fonts (Node.js only)
function fonts(callback);
function fontsSync();

Font Management

Configuration & Metadata

Configuration management, default settings, and font metadata access for advanced usage scenarios.

// Configure defaults
function defaults(options);

// Font metadata access
function metadata(fontName, callback);

// Font parsing
function parseFont(fontName, data);

// Internal font storage (read-only access)
figlet.figFonts;

Configuration

Common Types

// Options interface for text generation
interface FigletOptions {
  font?: string;                    // Font name (default: "Standard")
  horizontalLayout?: string;        // "default" | "full" | "fitted" | "controlled smushing" | "universal smushing"
  verticalLayout?: string;          // "default" | "full" | "fitted" | "controlled smushing" | "universal smushing"
  width?: number;                   // Text width limit (-1 for unlimited)
  whitespaceBreak?: boolean;        // Enable whitespace-aware line breaking
  printDirection?: number;          // 0 = left-to-right, 1 = right-to-left
  showHardBlanks?: boolean;         // Show hard blank characters
}

// Font metadata structure
interface FontMetadata {
  hardBlank: string;
  height: number;
  baseline: number;
  maxLength: number;
  oldLayout: number;
  numCommentLines: number;
  printDirection: number;
  fullLayout: number;
  codeTagCount: number;
  fittingRules: object;
}

// Error types
class Error {
  message: string;
  name: string;
}
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/figlet@1.8.x
Publish Source
CLI
Badge
tessl/npm-figlet badge