1.0.6 • Published 4 years ago

canvas-font-metrics v1.0.6

Weekly downloads
14
License
MIT
Repository
github
Last release
4 years ago

A performant javascript library that provides useful font metrics, including:

  • Ascent
  • Cap height
  • Tittle
  • X-Height
  • Baseline
  • Available ligatures
  • Available glyphs

It uses the Font Face Observer library to ensure the fonts are loaded before providing metrics.

Note: This library provides some metrics that aren't neccessary for most use cases (ligature and glyph detection, for instance). The bulk of the filesize comes from the inclusion of Adobe's 'Blank' font, which is used to detect what glyphs are available in a font. This functionality can be removed, if needed.

Installation

yarn add canvas-font-metrics

Usage

import CanvasFontMetrics from 'canvas-font-metrics'

var metrics = await CanvasFontMetrics({
	fontFamily: 'Helvetica',
	fontWeight: 400,
	fontStyle: 'normal',
	options: null // override default options
})

/*

metrics {
	capHeight,
	baseline,
	xHeight,
	descent,
	ascent,
	tittle,
	ligatures,
	getGlyphs,
	measureWidth,
	measureText
}

*/

To do: Finish documentation

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago