# fontname

> 🅰️ Parse font file (TTF, OTF) metadata like font family name.

Latest version **1.0.1** (published 2022-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install fontname
pnpm add fontname
yarn add fontname
bun add fontname
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-10-20 |
| First published | 2018-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/fontname) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Dan Bovey |
| Maintainers | danbovey |
| Keywords | fontname, familyname, font, parser, postscriptname, postscript |

## Links

- npm: https://www.npmjs.com/package/fontname
- Repository: https://github.com/danbovey/fontname
- Homepage: https://github.com/danbovey/fontname#readme
- Issues: https://github.com/danbovey/fontname/issues
- npm.io page: https://npm.io/package/fontname

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-10-20
- 1.0.0 — 2018-11-07

## README

# fontname

> 🅰️ Parse font file (TTF, OTF) metadata like font family name.

[![](https://img.shields.io/npm/v/fontname.svg)](https://www.npmjs.com/package/fontname)

## Demo

Upload a font and see the results at: https://danbovey.uk/fontname

## Install

`npm install fontname`

`yarn add fontname`

## Usage

`FontName.parse(ArrayBuffer)`

Parses an ArrayBuffer (binary data of the font from a FileReader) and returns an object with font meta. Throws on failure.

### Example (browser)

```js
import FontName from 'fontname';

const fontFile = e.target.files[0]; // File
const reader = new FileReader();
reader.onload = e => {
  const buffer = e.target.result; // ArrayBuffer
  try {
    const fontMeta = FontName.parse(e.target.result)[0];
    console.log(fontMeta);
  } catch (e) {
    // FontName may throw an Error
  }
};
reader.readAsArrayBuffer(fontFile);
```

### Example (node)

```js
const fs = require('fs');
const FontName = require('fontname');

try {
  const fontMeta = FontName.parse(fs.readFileSync('font.tff'))[0];
  console.log(fontMeta);
} catch (e) {
  // FontName may throw an Error
}
```

### Returns

```json
{
  "copyright": "Copyright 2011 Google Inc. All Rights Reserved.",
  "_lang": 0,
  "fontFamily": "Roboto",
  "fontSubfamily": "Regular",
  "ID": "Roboto",
  "fullName": "Roboto",
  "version": "Version 2.137; 2017",
  "postScriptName": "Roboto-Regular",
  "trademark": "Roboto is a trademark of Google.",
  "designer": "Google",
  "urlVendor": "Google.com",
  "urlDesigner": "Christian Robertson",
  "licence": "Licensed under the Apache License, Version 2.0",
  "licenceURL": "http://www.apache.org/licenses/LICENSE-2.0"
}
```

## License

File parsing logic from [Typr.js](https://github.com/photopea/Typr.js).

---
_Source: https://npm.io/package/fontname · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
