font-measure
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -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 [](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) |
10239
228
79
+ Addedcss-font@^1.2.0
+ Addedcss-font@1.2.0(transitive)
+ Addedcss-font-size-keywords@1.0.0(transitive)
+ Addedcss-font-stretch-keywords@1.0.1(transitive)
+ Addedcss-font-style-keywords@1.0.1(transitive)
+ Addedcss-font-weight-keywords@1.0.0(transitive)
+ Addedcss-global-keywords@1.0.1(transitive)
+ Addedcss-system-font-keywords@1.0.0(transitive)
+ Addedparenthesis@3.1.8(transitive)
+ Addedpick-by-alias@1.2.0(transitive)
+ Addedstring-split-by@1.0.0(transitive)
+ Addedunquote@1.1.1(transitive)
- Removedobject-assign@^4.1.1
- Removedobject-assign@4.1.1(transitive)