Marker types representing different coordinate spaces. You probably won't use these directly, but use the type aliases which use these as type parameters instead.
The design coordinate space
The normalized coordinate space
A union of all coordinate spaces
The user coordinate space
Types representing individual coordinate values in different spaces. By applying typings to these coordinates, it becomes impossible to mix them up accidentally. For example
const defaultValue: UserspaceCoordinate = 400;
const min: DesignspaceCoordinate = 24;
const max: UserspaceCoordinate = 900;
const axis: Axis = {
tag: 'wght',
name: 'Weight',
min, // Won't compile, type error
max,
default: defaultValue
};
A coordinate in a specific coordinate space
A coordinate in design space
A coordinate in normalized space
A coordinate in user space
Create a normalized space coordinate, clamped to -1.0 to 1.0
Types representing mappings of axis names to coordinates, hence representing a location in some coordinate space; for example:
const location1: DesignspaceLocation = {wght: 120, wdth: 1};
const location2: UserspaceLocation = {wght: 400, wdth: 75};
A location in design space
A location, in some coordinate space
A location in normalized space
A location in user space
Types and functions to help move between different coordinate spaces.
An array which maps design space coordinates to user space coordinates
A piecewise linear mapping between coordinate spaces
An array which maps user space coordinates to design space coordinates
Convert a designspace location to a userspace location
Convert a designspace location to a normalized location
Normalize a designspace coordinate to normalized space
Map a coordinate between spaces
Convert a userspace location to a designspace location
A variable font axis
Represents an OpenType variation model for a set of masters
Represents the support region of a master in a variation model
Return the support scalar for a given location and support
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.