Name: measure-text
Owner: Formidable
Description: An efficient text measurement function for the browser.
Created: 2016-02-12 01:25:17.0
Updated: 2018-01-04 20:26:11.0
Pushed: 2016-10-04 19:30:43.0
Homepage: null
Size: 92
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
An efficient text measurement function for the browser.
t measurement = measureText({
xt: "The quick brown fox jumps over the lazy dog",
ntFamily: "Georgia",
ntSize: "2em",
neHeight: 1.3,
ntWeight: 700,
ntStyle: "italic"
measureText
accepts the following parameter object:
text: string|Array<string>
the text to measure. Measures multiline text if provided an array.fontFamily: string
the font family of the text.fontSize: string
the size of the font. All CSS units work here.lineHeight: string|number
the line height of the text. measureText
assumes the lineHeight
to be a unitless CSS value if provided either a number or a string with no unit. Any other string acts as a CSS value.fontWeight: string|number
the weight of the text. Accepts numeric and textual weights.fontStyle: string
the style of the font.canvas: HTMLCanvasElement
a canvas instance to use instead of the default global canvas.