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

@simoncozens/fonttypes

v1.0.0

Published

Strongly typed functions for manipulating font source objects

Readme

fonttypes

This is fonttypes, a TypeScript library for font engineering. It will be primarily useful for people working with variable fonts, especially at the source level; it includes types for designspaces, coordinates, locations, variation models, and provides utility functions for OpenType interpolation.

Installation

npm install fonttypes

Usage

This library uses branded types to ensure that you don't mix up different coordinate spaces. For example, you can't pass a UserspaceCoordinate to a function that expects a DesignspaceCoordinate. It also provides functions to convert between these spaces, and to normalize locations for interpolation.

It provides a VariationModel class that can be used to perform interpolation given a set of master locations and corresponding values.

Here's an example of how to use the library to convert between coordinate spaces and interpolate a value in a variable font.

import {
  UserspaceCoordinate,
  DesignspaceLocation,
  UserspaceLocation,
  UserspaceToDesignspaceMapping,
  Axis,
  userspaceToDesignspace,
  normalizeLocation,
  VariationModel,
  NormalizedLocation,
} from "fonttypes";

// Define the axes for a variable font
let weightMap: UserspaceToDesignspaceMapping = [
  [100, 100],
  [400, 400],
  [700, 600],
  [900, 900],
];

let axisMin: DesignspaceCoordinate = 100;
const axes: Axis[] = [
  {
    tag: "wght",
    name: "Weight",
    min: axisMin, // Oops, this won't compile!
    default: 400,
    max: 900,
    map: weightMap,
  },
];

// Convert a userspace location to a designspace location
const userLocation: UserspaceLocation = { wght: 650 };
const designLocation: DesignspaceLocation = userspaceToDesignspace(
  userLocation,
  axes,
);
console.log("Designspace location:", designLocation);
// -> Designspace location: { wght: 550 }

// Normalize the designspace location
const normalizedLocation: NormalizedLocation = normalizeLocation(
  designLocation,
  axes,
);
console.log("Normalized location:", normalizedLocation);
// -> Normalized location: { wght: 0.3 }

// --- Interpolation ---

// Define master locations in normalized space
const masterLocations: NormalizedLocation[] = [
  { wght: 0.0 },
  { wght: -1.0 },
  { wght: 1.0 },
];

// Create a variation model
const model = new VariationModel(masterLocations, ["wght"]);

// Values for a glyph component's x-position at each master location
const masterValues = [150, 100, 250]; // Corresponds to default, min, max

// Interpolate the x-position at our normalized location
const interpolatedValue = model.interpolateFromMasters(
  normalizedLocation,
  masterValues,
);

console.log("Interpolated value:", interpolatedValue);
// -> Interpolated value: 180

Building and Testing

To build the library from source, run:

npm run build

To run the tests, use:

npm run test

API Documentation

Full API documentation is available at https://simoncozens.github.io/fonttypes/