# node-freetype

> nodejs freetype binding and more functions

Latest version **1.1.0** (published 2015-07-08) · Apache license · 0 weekly downloads

## Install

```sh
npm install node-freetype
pnpm add node-freetype
yarn add node-freetype
bun add node-freetype
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2015-07-08 |
| First published | 2014-10-25 |
| Weekly downloads | 0 |
| License | Apache |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 5 |
| Author | Yuhang Ge |
| Maintainers | yuhangge |
| Keywords | font, freetype, woff, ttf |

## Links

- npm: https://www.npmjs.com/package/node-freetype
- Repository: https://github.com/YuhangGe/node-freetype
- Issues: https://github.com/YuhangGe/node-freetype/issues
- npm.io page: https://npm.io/package/node-freetype

## Dependencies (3)

- [nan](https://npm.io/package/nan.md) ~1.8.4
- [pako](https://npm.io/package/pako.md) ^0.2.5
- [underscore](https://npm.io/package/underscore.md) ^1.7.0

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads
- [@react-md/material-icons](https://npm.io/package/@react-md/material-icons.md) — 1.6K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2015-07-08
- 1.0.5 — 2014-11-03
- 1.0.4 — 2014-10-31
- 1.0.3 — 2014-10-31
- 1.0.2 — 2014-10-29
- 1.0.1 — 2014-10-29
- 1.0.0 — 2014-10-25

## README

node-freetype
============

nodejs [freetype](www.freetype.org) binding, inspired by(and modified from)
 [freetype2](https://github.com/ericfreese/node-freetype2.git),
 [svg2ttf](https://github.com/fontello/svg2ttf),
 [ttf2woff](https://github.com/fontello/ttf2woff),
 and [opentype.js](https://github.com/nodebox/opentype.js.git),
 but keep focus on opentype(ttf, otf and woff), and can extract sub charset and create new font file.
  
meanwhile, node-freetype do not parse all glyphs at once like [opentype.js](https://github.com/nodebox/opentype.js.git),
so it will take little time to load big font file.

Usage
--------
    
    var freetype = require('node-freetype');
    var fs = require('fs');
    var path = require('path');
    var _ = require('underscore');
    
    
    var src = fs.readFileSync('NotoSansHans-Black.ttf');
    var font = freetype.parse(src);
    
    console.log(font.tables.head);
    console.log(font.tables.head.magicNumber.toString(16));
    console.log(font.tables.name);
    console.log(font.info);
    console.log(font.tables.maxp);
    console.log(font.tables.os2);
    console.log(font.tables.pclt);
    console.log(font.tables.post);
    console.log(font.tables.vhea);
    console.log(font.tables.hhea);

    console.log(font.getCharGlyph("a"));
    console.log(font.getCharIndex("a"));
    console.log(font.getGlyphName("a"));

    var ttf = font.generateSubFont('a bcd1234ac葛羽航中国制造');
    var ttf_buffer = ttf.toTTF();
    fs.writeFileSync('test.ttf', ttf_buffer);

    var woff_buffer = ttf.toWOFF();
    fs.writeFileSync('test.woff', woff_buffer);

Todo
-------
* support open otf file format

Bugs
------
* 在将NotoSansHans-Black.ttf文件转换后，字母和数字的宽度有问题。见test.html在chrome下的表现。
  (open test.html under test directory with Chrome and you will see this bug. but we ignore
  test directory in npm. see github files).

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