npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-pango

v1.0.0

Published

High-fidelity Node.js wrapper for pango-view CLI with HTML support and font-by-path rendering

Readme

node-pango

A high-fidelity Node.js wrapper for the pango-view CLI utility with advanced features including HTML support and font-by-path rendering.

Features

  • 🚀 Async Process Management: Uses execa for robust subprocess handling
  • 🎨 Font-by-Path Support: Render fonts directly from .ttf or .otf files
  • 🌐 HTML-to-Pango Conversion: Automatic translation of HTML tags to Pango markup
  • 📐 Full API Coverage: Supports all pango-view flags and options
  • 🖼️ Multiple Output Formats: PNG, SVG, and PDF rendering via Cairo backend
  • 💪 TypeScript Support: Full type definitions included

Installation

npm install node-pango

Prerequisites: You must have pango-view installed on your system.

Installing pango-view

macOS:

brew install pango

Ubuntu/Debian:

sudo apt-get install libpango1.0-dev pango1.0-tools

Fedora:

sudo dnf install pango-devel pango-tools

Quick Start

const PangoView = require('node-pango');

const pango = new PangoView({
  text: 'Hello, <b>World</b>!',
  width: 300,
  output: 'output.png'
});

await pango.render();

API Reference

Constructor Options

const pango = new PangoView({
  // Text content (required)
  text: 'Your text here',
  
  // Output file (required)
  output: 'output.png',
  
  // Font options
  font: 'Sans 12',
  fontFile: './path/to/font.ttf', // Font-by-path support
  
  // Dimensions
  width: 400,
  height: 300,
  
  // Layout options
  align: 'left',        // left, right, center
  justify: false,
  indent: 0,
  spacing: 0,
  lineSpacing: 1.0,
  
  // Format options
  markup: false,        // Set to true if text already contains Pango markup
  htmlMode: true,       // Parse HTML tags (default: true)
  
  // Advanced options
  wrap: 'word',         // word, char, word-char
  ellipsize: 'end',     // start, middle, end
  annotate: 0,          // Rectangle annotation level (0-2)
  
  // Cairo backend options
  backend: 'png',       // png, svg, pdf
  dpi: 96,
  
  // Environment
  pangoViewPath: 'pango-view' // Custom path to pango-view binary
});

Methods

render()

Renders the text and writes output to the specified file.

await pango.render();

Returns: Promise<void>

renderToBuffer()

Renders the text and returns the output as a Buffer.

const buffer = await pango.renderToBuffer();

Returns: Promise<Buffer>

getMarkup()

Returns the Pango markup that will be rendered (useful for debugging).

const markup = pango.getMarkup();
console.log(markup);

Returns: string

HTML Support

The package automatically converts HTML tags to Pango markup:

const pango = new PangoView({
  text: `
    <h1>Title</h1>
    <p>This is <strong>bold</strong> and <em>italic</em> text.</p>
    <p>You can also use <u>underline</u> and <font color="red">colors</font>.</p>
  `,
  output: 'output.png',
  htmlMode: true
});

await pango.render();

Supported HTML Tags

| HTML Tag | Pango Markup | Description | |----------|--------------|-------------| | <strong>, <b> | <span weight="bold"> | Bold text | | <em>, <i> | <span style="italic"> | Italic text | | <u> | <span underline="single"> | Underlined text | | <s>, <strike> | <span strikethrough="true"> | Strikethrough | | <font color="..."> | <span foreground="..."> | Text color | | <font size="..."> | <span size="..."> | Font size | | <font face="..."> | <span font_family="..."> | Font family | | <sup> | <span rise="positive"> | Superscript | | <sub> | <span rise="negative"> | Subscript | | <small> | <span size="small"> | Small text | | <big> | <span size="large"> | Large text |

Font-by-Path Support

Render text using a specific font file without installing it system-wide:

const pango = new PangoView({
  text: 'Custom Font Rendering',
  fontFile: './fonts/MyCustomFont.ttf',
  font: 'MyCustomFont 24',
  output: 'output.png'
});

await pango.render();

This feature:

  • Dynamically generates a temporary fonts.conf XML file
  • Sets the FONTCONFIG_FILE environment variable
  • Cleans up temporary files after rendering

Advanced Examples

SVG Output with Custom Layout

const pango = new PangoView({
  text: 'Lorem ipsum dolor sit amet...',
  output: 'output.svg',
  backend: 'svg',
  width: 500,
  align: 'justify',
  wrap: 'word',
  font: 'Serif 14',
  lineSpacing: 1.5
});

await pango.render();

PDF Output with Annotations

const pango = new PangoView({
  text: 'Annotated Text',
  output: 'output.pdf',
  backend: 'pdf',
  annotate: 2, // Full annotation
  font: 'Mono 10'
});

await pango.render();

Buffer Output for Streaming

const pango = new PangoView({
  text: 'Buffer output',
  output: 'temp.png'
});

const buffer = await pango.renderToBuffer();
// Use buffer for streaming, uploading, etc.

Error Handling

try {
  await pango.render();
} catch (error) {
  if (error.code === 'ENOENT') {
    console.error('pango-view not found. Please install Pango.');
  } else {
    console.error('Rendering failed:', error.message);
  }
}

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.