calculate-size
Calculate the pixel size of a string
Last updated 10 years ago by schickling .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install calculate-size 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.1.1                                ...           latest (10 years ago)

7 Versions

  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.2                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 18
Today 0
This Week 1
This Month 9
Last Day 0
Last Week 8
Last Month 1
Dependencies (0)
None
Dev Dependencies (4)

© 2010 - cnpmjs.org x YWFE | Home | YWFE