calculate-size

Calculate the pixel size of a string

MIT 7 个版本
安装
npm install calculate-size
yarn add calculate-size
pnpm add calculate-size
bun add calculate-size
README

calculate-size Build Status npm version

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

Install

This package supports Typescript out-of-the-box

$ npm install calculate-size

Usage

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
版本列表
1.1.1 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