Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

font-measure

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

font-measure

Calculate metrics of a font

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
145K
decreased by-22.34%
Maintainers
1
Weekly downloads
 
Created
Source

font-measure unstable

Calculate metrics for a font metrics.

npm install font-measure

let measure = requrie('font-measure')

measure('Roboto')

/*
{
  top: 0,
  bottom: 1.3125,
  lower: 0.515625,
  upper: 0.328125,
  xHeight: 0.53125,
  alphabetic: 1.046875,
  baseline: 1.046875,
  capHeight: 0.71875,
  median: 0.65625,
  middle: 0.65625,
  ascent: 0.28125,
  descent: 0.328125,
  hanging: 0.21875,
  ideographic: 1,
  lineHeight: 1.3125,
  tittle: 0.28125,
  overshoot: 0
}
 */

API

metrics = measure(font|options)

Get metrics data for a font or custom options.

metrics:
options:
PropertyDefaultMeaning
familynullFont-family to detect metrics. Can be a string or an array (fontstack).
origintopOrigin for metrics. Can be changed to baseline or any other metric.
size64Font-size to use for calculations. Larger size gives higher precision with slower performance.
canvasmeasure.canvasCanvas to use for measurements.
tittleiCharacter to detect tittle. Null value ignores calculation.
descentpCharacter to detect descent line. Null value ignores calculation.
ascenthCharacter to detect ascent line. Null value ignores calculation.
overshootOCharacter to detect overshoot. Null value ignores calculation.
upperHCharacter to detect upper line / cap-height. Null value ignores calculation.
lowerxCharacter to detect lower line / x-height. Null value ignores calculation.

See also

  • optical-properties − calculate image/character optical center and bounding box.
  • detect-kerning − calculate kerning pairs for a font.

There are many text / font measuring packages for the moment, but most of them don't satisfy basic quality requirements. Special thanks to @soulwire for fontmetrics as model implementation.

License

© 2018 Dima Yv. MIT License

Development supported by plot.ly.

Keywords

FAQs

Package last updated on 19 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc