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

@pictogrammers/fnt

v1.2.0

Published

Parse and serialize the [AngelCode BMFont](https://www.angelcode.com/products/bmfont/doc/file_format.html) binary format (`.fnt`).

Readme

@pictogrammers/fnt

Parse and serialize the AngelCode BMFont binary format (.fnt).

Supports Node.js and the browser. No runtime dependencies.

Install

npm install @pictogrammers/fnt

API

import { readFnt, writeFnt } from '@pictogrammers/fnt';

readFnt(input: Uint8Array | ArrayBuffer): FntFont
writeFnt(font: FntFont): Uint8Array

FntFont

interface FntFont {
  info: FntInfo;       // face name, size, flags, padding, spacing
  common: FntCommon;   // line height, texture dimensions, channel layout
  pages: string[];     // texture filenames, one per page
  chars: FntChar[];    // per-glyph texture coordinates and metrics
  kernings: FntKerning[];
}

See shared.ts for the full type definitions.


Node.js

Read a font

import { readFileSync } from 'fs';
import { readFnt } from '@pictogrammers/fnt';

const font = readFnt(readFileSync('OpenSans-Regular-16.fnt'));

console.log(font.info.face);        // "Open Sans"
console.log(font.info.fontSize);    // -13163  (Windows LOGFONT signed height)
console.log(font.common.lineHeight); // 21
console.log(font.pages);            // ["OpenSans-Regular-16.png"]
console.log(font.chars.length);     // 95
console.log(font.kernings.length);  // 23

Inspect glyphs

// Find the metrics for a specific character
const glyph = font.chars.find(c => c.char === 'A');
if (glyph) {
  console.log(glyph.x, glyph.y);           // position in texture atlas
  console.log(glyph.width, glyph.height);  // size in texture atlas
  console.log(glyph.xoffset, glyph.yoffset, glyph.xadvance);
}

// Get kerning between two characters
const kern = font.kernings.find(k => k.firstChar === 'T' && k.secondChar === 'a');
console.log(kern?.amount); // -1

Write a font

import { readFileSync, writeFileSync } from 'fs';
import { readFnt, writeFnt } from '@pictogrammers/fnt';

const font = readFnt(readFileSync('OpenSans-Regular-16.fnt'));

// Modify and write back
font.info.outline = 1;

writeFileSync('OpenSans-Regular-16-modified.fnt', writeFnt(font));

Convert to JSON

import { readFileSync, writeFileSync } from 'fs';
import { readFnt } from '@pictogrammers/fnt';

const font = readFnt(readFileSync('OpenSans-Regular-16.fnt'));
writeFileSync('OpenSans-Regular-16.json', JSON.stringify(font, null, 2));

Web

Read via fetch

import { readFnt } from '@pictogrammers/fnt';

const font = readFnt(await fetch('fonts/OpenSans-Regular-16.fnt').then(r => r.arrayBuffer()));

console.log(font.info.face);         // "Open Sans"
console.log(font.common.lineHeight); // 21

Read via file picker

import { readFnt } from '@pictogrammers/fnt';

async function openFont() {
  const [handle] = await window.showOpenFilePicker({
    types: [{ description: 'BMFont', accept: { 'application/octet-stream': ['.fnt'] } }],
  });
  const file = await handle.getFile();
  return readFnt(await file.arrayBuffer());
}

const font = await openFont();
console.log(font.info.face);

Write via file picker (save)

import { writeFnt } from '@pictogrammers/fnt';

async function saveFont(font) {
  const handle = await window.showSaveFilePicker({
    suggestedName: 'font.fnt',
    types: [{ description: 'BMFont', accept: { 'application/octet-stream': ['.fnt'] } }],
  });
  const writable = await handle.createWritable();
  await writable.write(writeFnt(font));
  await writable.close();
}

Write via download link

import { writeFnt } from '@pictogrammers/fnt';

function downloadFont(font, filename = 'font.fnt') {
  const url = URL.createObjectURL(new Blob([writeFnt(font)], { type: 'application/octet-stream' }));
  Object.assign(document.createElement('a'), { href: url, download: filename }).click();
  URL.revokeObjectURL(url);
}

Fonts

The fonts included in this repo are for testing only borrowed from the Moddable SDK.