CommonJS command to retrieve information about a font (Mac only)
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
README.md
package.json
sources.json

README.md

fontinfo

A CommonJS command to retrieve information about a font.

Usage

var info = require("fontinfo").fontinfo(font, size);

The font must be a full PostScript name, not a display name. So you would use something like "LucidaGrande-Bold", not "Lucida Grande Bold". The size can be any floating point number greater than zero.

Results

If the font can be found, fontinfo returns a Javascript object with the following structure:

{
	familyName: <string>,
	bold: <boolean>,
	italic: <boolean>,
	ascender: <float>,
	descender: <float>,
	lineHeight: <float>
}

The fields of the object are as follows:

familyName: The display name of the font's family
bold: Whether the font's stylistic traits are considered bold
italic: Whether the font's stylistic traits are considered italic
ascender: The offset from the baseline in points (not pixels!) of the longest ascender of the given font at
		  the given size.
descender: The negative offset from the baseline in points (not pixels!)
		   of the longest descender of the given font at the given size.
lineHeight: The height in points (not pixels!) of the largest glyph in the given font at the given size.
			Note that glyphs include diacritical marks that may appear above and below the largest ascender 
			and descender, so the line height will almost always be greater than ascender + descender.

Credits

Copyright (c) Aparajita Fishman.