https://github.com/hustcc/bmt
:straight_ruler: in Browser, Measure Text width.
https://github.com/hustcc/bmt
canvas measure-text string-width
Last synced: about 1 month ago
JSON representation
:straight_ruler: in Browser, Measure Text width.
- Host: GitHub
- URL: https://github.com/hustcc/bmt
- Owner: hustcc
- License: mit
- Created: 2020-01-15T11:34:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-03T02:30:01.000Z (about 5 years ago)
- Last Synced: 2025-02-28T19:12:10.527Z (about 2 months ago)
- Topics: canvas, measure-text, string-width
- Language: TypeScript
- Homepage: https://github.com/hustcc/bmt
- Size: 45.9 KB
- Stars: 13
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# bmt
> in **B**rowser, **M**easure **T**ext width.
[](https://www.npmjs.com/package/bmt)
[](https://github.com/hustcc/bmt/actions)
[](https://coveralls.io/github/hustcc/bmt?branch=master)
[](https://www.npmjs.com/package/bmt)## Install
```bash
$ npm i --save bmt
```## Usage
```ts
import { measureTextByDOM, measureTextByCanvas } from 'bmt';const font = {
fontFamily: 'sans-serif',
fontSize: 16,
};measureTextByDOM('hello world', font); // = 80
measureTextByCanvas('hello world', font); // ~= 80
```## Perf
Run on your computer.
```bash
$ npm run perf
```## License
MIT@[hustcc](https://github.com/hustcc).