font-fit
v0.3.7
Published
A fast, lightweight library for sizing text-content to fit.
Downloads
62
Readme
font-fit
A fast, lightweight library for sizing text-content to fit.
Demo
Installation
$ npm install font-fit
Usage
var result = fontFit({
text: 'hello world',
font: 'italic 24px arial',
space: myElement.clientWidth, // space for text,
min: 16, // min font-size (optional)
max: 24 // max font-size (optional)
});
myElement.style.fontSize = result.fontSize + 'px';
Tests
- Ensure Firefox Nightly is installed on your machine.
$ npm install
$ npm test
If your would like tests to run on file change use:
$ npm run test-dev