New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

6

index.js

@@ -19,3 +19,5 @@ 'use strict'

var fs = o.size || o.fontSize || o.em || 48
var font = fs + 'px ' + family
var weight = o.weight || o.fontWeight || ''
var style = o.style || o.fontStyle || ''
var font = [style, weight, fs].join(' ') + 'px ' + family
var origin = o.origin || 'top'

@@ -26,3 +28,3 @@

if (fs <= measure.cache[family].em) {
return origin === 'top' ? measure.cache[family] : applyOrigin(measure.cache[family], origin)
return applyOrigin(measure.cache[family], origin)
}

@@ -29,0 +31,0 @@ }

{
"name": "font-measure",
"version": "1.1.1",
"version": "1.2.0",
"description": "Calculate metrics of a font",

@@ -38,4 +38,4 @@ "main": "index.js",

"dependencies": {
"object-assign": "^4.1.1"
"css-font": "^1.2.0"
}
}

@@ -38,5 +38,5 @@ # font-measure [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges)

### `let metrics = measure(font, options?)`
### `let metrics = measure(family, options?)`
Get metrics data for a font, possibly with custom options. Font can be a string or an array with fonts.
Get metrics data for a font family or [CSS font string](), possibly with custom options. Font can be a string or an array with fonts.

@@ -53,3 +53,5 @@ #### `metrics`:

`origin` | `top` | Origin for metrics. Can be changed to `baseline` or any other metric.
`size` | `64` | Font-size to use for calculations. Larger size gives higher precision with slower performance.
`fontSize` | `64` | Font-size to use for calculations. Larger size gives higher precision with slower performance.
`fontWeight` | `normal` | Font weight to use for calculations, eg. `bold`, `700` etc.
`fontStyle` | `normal` | Font style to use for calculations, eg. `italic`, `oblique`.
`canvas` | `measure.canvas` | Canvas to use for measurements.

@@ -56,0 +58,0 @@ `tittle` | `i` | Character to detect tittle. `null` disables calculation.

@@ -6,2 +6,3 @@ 'use strict'

let fix = {

@@ -28,2 +29,3 @@ alphabetic: 1.03125,

a.deepEqual(m('Roboto', {fontSize: 64}), fix)
a.deepEqual(m('Roboto', {fontSize: 64, fontWeight: '700', fontStyle: 'italic'}), fix)
a.equal(m('Roboto', {fontSize: 64, origin: 'baseline'}).baseline, 0)
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