# calculate-size

> Calculate the pixel size of a string

Latest version **1.1.1** (published 2016-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install calculate-size
pnpm add calculate-size
yarn add calculate-size
bun add calculate-size
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2016-12-08 |
| First published | 2015-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 121 |
| Author | Johannes Schickling |
| Maintainers | schickling |
| Keywords | font, calculate, size, width, height, dimension |

## Links

- npm: https://www.npmjs.com/package/calculate-size
- Repository: https://github.com/schickling/calculate-size
- Issues: https://github.com/schickling/calculate-size/issues
- npm.io page: https://npm.io/package/calculate-size

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2016-12-08
- 1.1.0 — 2016-12-08
- 1.0.2 — 2016-12-07
- 1.0.1 — 2016-12-07
- 1.0.0 — 2016-12-07
- 0.2.0 — 2016-05-19
- 0.1.0 — 2015-05-25

## README

calculate-size [![Build Status](https://travis-ci.org/schickling/calculate-size.svg?branch=master)](https://travis-ci.org/schickling/calculate-size) [![npm version](https://badge.fury.io/js/calculate-size.svg)](https://badge.fury.io/js/calculate-size)
==============

Calculate the pixel size (width/height) of a string (with integrated caching)

## Install

> This package supports Typescript out-of-the-box

```sh
$ npm install calculate-size
```

## Usage

```js
const size = calculateSize('Hello world!', {
   font: 'Arial',
   fontSize: '12px'
})

### Options

* `font: string`
* `fontSize: string`
* `fontWeight: string`
* `width: string` (Constraint width by a fixed value to calc height)

console.log(size.width) // 140
console.log(size.height) // 20
```

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