# measure-text

> An efficient text measurement function for the browser.

Latest version **0.0.4** (published 2016-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install measure-text
pnpm add measure-text
yarn add measure-text
bun add measure-text
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2016-03-02 |
| First published | 2016-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 23 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 87 |
| Maintainers | tptee |

## Links

- npm: https://www.npmjs.com/package/measure-text
- Repository: https://github.com/FormidableLabs/measure-text
- Issues: https://github.com/FormidableLabs/measure-text/issues
- npm.io page: https://npm.io/package/measure-text

## Dependencies (23)

- [rimraf](https://npm.io/package/rimraf.md) ^2.5.0
- [webpack](https://npm.io/package/webpack.md) ^2.0.7-beta
- [babel-cli](https://npm.io/package/babel-cli.md) ^6.4.5
- [units-css](https://npm.io/package/units-css.md) ^0.4.0
- [babel-core](https://npm.io/package/babel-core.md) ^6.4.5
- [css-loader](https://npm.io/package/css-loader.md) ^0.23.1
- [url-loader](https://npm.io/package/url-loader.md) ~0.5.7
- [file-loader](https://npm.io/package/file-loader.md) ^0.8.5
- [lodash.omit](https://npm.io/package/lodash.omit.md) ^4.0.1
- [babel-loader](https://npm.io/package/babel-loader.md) ^6.2.1
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.0.1
- [style-loader](https://npm.io/package/style-loader.md) ^0.13.0
- [lodash.isfinite](https://npm.io/package/lodash.isfinite.md) ^3.3.0
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.0.1
- [babel-preset-react](https://npm.io/package/babel-preset-react.md) ^6.3.13
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) ^6.3.13
- [babel-preset-stage-2](https://npm.io/package/babel-preset-stage-2.md) ^6.3.13
- [babel-preset-es2015-webpack](https://npm.io/package/babel-preset-es2015-webpack.md) ^6.3.13
- [babel-plugin-syntax-decorators](https://npm.io/package/babel-plugin-syntax-decorators.md) ^6.3.13
- [babel-plugin-transform-runtime](https://npm.io/package/babel-plugin-transform-runtime.md) ^6.4.3
- [babel-plugin-syntax-class-properties](https://npm.io/package/babel-plugin-syntax-class-properties.md) ^6.3.13
- [babel-plugin-transform-class-properties](https://npm.io/package/babel-plugin-transform-class-properties.md) ^6.4.0
- [babel-plugin-transform-decorators-legacy](https://npm.io/package/babel-plugin-transform-decorators-legacy.md) ^1.3.4

## Recent versions

- 0.0.4 (latest) — 2016-03-02
- 0.0.3 — 2016-02-17
- 0.0.2 — 2016-02-16

## README

# measure-text
An efficient text measurement function for the browser.

## API

```es6
const measurement = measureText({
  text: "The quick brown fox jumps over the lazy dog",
  fontFamily: "Georgia",
  fontSize: "2em",
  lineHeight: 1.3,
  fontWeight: 700,
  fontStyle: "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.
  - The following units are not supported: "%", "ch", "cm", "em", "ex"
- `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.

---
_Source: https://npm.io/package/measure-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
