JSPM

freetype2_render

1.3.11
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 251
  • Score
    100M100P100Q63291F
  • License MIT

Parse font files with FreeType.

Package Exports

  • freetype2_render

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (freetype2_render) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Node FreeType

Build Status

A Node native addon that uses FreeType to parse font files.

FreeType is a freely available software library to render fonts. http://www.freetype.org/

Install

npm install freetype2

Usage

var fs = require('fs'),
    freetype = require('freetype2');

fs.readFile('/path/to/a/font.woff', function(err, buffer) {
  if (!!err) throw err;
  var fontface = freetype.parse(buffer);
  console.log(fontface);
});

The module exports a parse function, which takes the raw font file data and returns a FontFace object with the following properties:

{
  num_faces: 1,
  face_index: 0,
  face_flags: 537,
  style_flags: 2,
  num_glyphs: 233,
  family_name: 'Nexa Bold',
  style_name: 'Regular',
  num_fixed_sizes: 0,
  num_charmaps: 4,
  units_per_EM: 1000,
  ascender: 750,
  descender: -250,
  height: 1000,
  max_advance_width: 1159,
  max_advance_height: 1000,
  underline_position: -100,
  underline_thickness: 50,
  available_characters: [ 32, 33, 34, 35, ... ]
}

available_characters is an array of character values that the font maps to glyphs. Use .toString(16) to get a hex string representation.

Built for https://github.com/ericfreese/font-viewer.