JSPM

@adam-rocska/font-anatomy

1.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q40686F
  • License MIT

A collection of tools for working with font anatomy in Typescript.

Package Exports

  • @adam-rocska/font-anatomy

Readme

Font Anatomy Tools for Typescript

npm version License

This is a collection of tools for working with font anatomy in Typescript.

Installation

pnpm add @adam-rocska/font-anatomy
npm install @adam-rocska/font-anatomy

Usage

Command Line Utilities

All utilities do and will assume inputs from stdin and outputs to stdout. This is to allow for easy chaining of commands and general composition.

Example with pnpx:

cat Poppins-BoldItalic.ttf | pnpx @adam-rocska/font-anatomy -o md > Poppins-BoldItalic.md

Example with a global install:

my-font.ttf | font-anatomy --output-format=md > font-anatomy.md

Library units

import { fromFontFile } from '@adam-rocska/font-anatomy';
import { relativize } from '@adam-rocska/font-anatomy';

// It takes a `PathLike` so you can pass a string, URL or a `Buffer`
const fontAnatomy = fromFontFile('path/to/font.ttf');
console.log(fontAnatomy);
/// {
///   unitsPerEm: 1000,
///   ascender: 800,
///   descender: -200,
///   xHeight: 500,
///   capHeight: 700
/// }

relativize('unitsPerEm', {
  unitsPerEm: 1000,
  ascender: 800,
  descender: -200,
  xHeight: 500,
  capHeight: 700
});

/// {
///   unitsPerEm: 1,
///   ascender: 0.8,
///   descender: -0.2,
///   xHeight: 0.5,
///   capHeight: 0.7,
/// }