Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adam-rocska/font-anatomy-typescript
A collection of tools for working with font anatomy in Typescript.
https://github.com/adam-rocska/font-anatomy-typescript
anatomy font fontanatomy fontface fonts javascript js node nodejs npx opentype pnpx ts typeface types typescript typescript-library typography typography-tools typographyanatomy
Last synced: 1 day ago
JSON representation
A collection of tools for working with font anatomy in Typescript.
- Host: GitHub
- URL: https://github.com/adam-rocska/font-anatomy-typescript
- Owner: adam-rocska
- License: mit
- Created: 2024-08-08T18:37:33.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-01-10T07:13:37.000Z (5 days ago)
- Last Synced: 2025-01-13T01:09:01.358Z (2 days ago)
- Topics: anatomy, font, fontanatomy, fontface, fonts, javascript, js, node, nodejs, npx, opentype, pnpx, ts, typeface, types, typescript, typescript-library, typography, typography-tools, typographyanatomy
- Language: TypeScript
- Homepage:
- Size: 86.9 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Font Anatomy Tools for Typescript
[![NPM Version](https://img.shields.io/npm/v/@adam-rocska/font-anatomy.svg)](https://www.npmjs.com/package/@adam-rocska/font-anatomy)
[![License](https://img.shields.io/npm/l/@adam-rocska/font-anatomy)](https://github.com/adam-rocska/font-anatomy-typescript/blob/master/LICENSE)| Aspect | Badge |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Minified | [![Minified](https://badgen.net/bundlephobia/min/@adam-rocska/font-anatomy)](https://bundlephobia.com/package/@adam-rocska/font-anatomy) |
| Minified + gzip | [![Minified + gzip](https://badgen.net/bundlephobia/minzip/@adam-rocska/font-anatomy)](https://bundlephobia.com/package/@adam-rocska/font-anatomy) |
| Dependency Count | [![Dependency Count](https://badgen.net/bundlephobia/dependency-count/@adam-rocska/font-anatomy)](https://bundlephobia.com/package/@adam-rocska/font-anatomy) |
| Tree-shaking Support | [![Tree-shaking Support](https://badgen.net/bundlephobia/tree-shaking/@adam-rocska/font-anatomy)](https://bundlephobia.com/package/@adam-rocska/font-anatomy) |This is a collection of tools for working with font anatomy
in Typescript.## Installation
```sh
pnpm add @adam-rocska/font-anatomy
``````sh
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`:
```zsh
cat Poppins-BoldItalic.ttf | pnpx @adam-rocska/font-anatomy -o md > Poppins-BoldItalic.md
```Example with a global install:
```sh
my-font.ttf | font-anatomy --output-format=md > font-anatomy.md
```### Library units
```ts
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,
/// }```