An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

# bmt

> in **B**rowser, **M**easure **T**ext width.

[![npm Version](https://img.shields.io/npm/v/bmt.svg)](https://www.npmjs.com/package/bmt)
[![Build Status](https://github.com/hustcc/bmt/workflows/build/badge.svg)](https://github.com/hustcc/bmt/actions)
[![Coverage Status](https://coveralls.io/repos/github/hustcc/bmt/badge.svg?branch=master)](https://coveralls.io/github/hustcc/bmt?branch=master)
[![npm License](https://img.shields.io/npm/l/bmt.svg)](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

perf

Run on your computer.

```bash
$ npm run perf
```

## License

MIT@[hustcc](https://github.com/hustcc).