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

war2-fnt

v2.3.1

Published

Simple lib designed to ease of manipulating Blizzard .fnt files used in Warcraft 2.

Readme

Warcraft 2 Font Library (war2-fnt)

A library and CLI tool to convert Blizzard's font files used in Warcraft 2 into BMFont format (text + PNG) and back. It also supports splitting fonts into individual character images for easy editing.

Special thanks to the Warcraft 2 forum community for documenting the file format. Original post

Features

  • Reader: Read .fnt files and convert them to BMFont format.
  • Writer: turn BMFont data back into binary .fnt files.
  • CLI: Command-line interface for quick conversions.
  • Split/Stitch: Break down fonts into individual images for editing and recombine them.
  • Palette Support: Specify custom palettes for better previews and easier editing.

Installation

npm install war2-fnt
# or
pnpm add war2-fnt

CLI Usage

You can use the CLI directly via npx or after installing globally.

1. Unpack (.fnt -> BMFont + PNG)

Converts a binary font file into a standard .fnt descriptor and a .png atlas.

npx war2-fnt unpack input.fnt --output ./output --palette palette.json
  • --output (-o): Output directory.
  • --palette (-p): (Optional) JSON file containing an array of color objects to use given indices. If omitted, a default palette is used.

2. Pack (BMFont + PNG -> .fnt)

Converts a BMFont file and its corresponding image atlas back into the Warcraft 2 binary format.

npx war2-fnt pack font.fnt font.png --output new_font.fnt --palette palette.json

3. Split (.fnt -> Single Images)

Extracts every character from the font into its own separate PNG file. Useful for manual editing.

npx war2-fnt split input.fnt --output ./chars --palette palette.json

Output:

  • char_32.png, [...], char_65.png, ...
  • metadata.json (Stores offsets and spacing info)

4. Stitch (Single Images -> .fnt)

Recombines a directory of character images and a metadata.json file into a binary .fnt file.

npx war2-fnt stitch ./chars --output new_font.fnt --palette palette.json

5. Info (.fnt Metadata)

Quickly inspect font metrics and glyph counts.

npx war2-fnt info input.fnt

6. Render (Text Preview)

Render a string of text into a PNG image for previewing.

# Simple text
npx war2-fnt render input.fnt "Hello World" -o preview.png

# Multi-palette JSON (Minecraft style)
npx war2-fnt render input.fnt '[{"text": "A", "palette": "grayscale"}, {"text": "B", "palette": "other"}]'

Palettes

You can define your own palettes by providing external JSON file (array of {r, g, b, a}). By default, the tool uses the grayscale palette.

Programmatic Usage

import { War2Font, fntToBMFontAndPixelData, FontChar } from "war2-fnt";
import * as fs from "fs";

// 1. Reading a font
const buffer = fs.readFileSync("font.fnt").buffer;
const font = War2Font.fromBuffer(buffer);
const chars = font.getChars();

// 2. Converting to BMFont
const result = fntToBMFontAndPixelData(buffer, "MyFont", "font.png");
fs.writeFileSync("font.fnt", result.BMFTextBuffer);
// result.pixelData contains raw palette indices

// 3. Creating from scratch
const myChars: FontChar[] = [];
const newChar = new FontChar(/*Basic char detail*/);
// edit your char here
myChars.push(newChar);

const newFont = War2Font.fromGlyphs(myChars, 1);
const binaryInfo = newFont.write();