1.1.0 • Published 6 years ago

text-measure v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

Install

$ npm install --save text-measure

Notice

only browser environment which support canvas(仅适用于支持html5 canvas的浏览器环境)

Usage

.
├── index.js
└── package.json
import measureText from text-measure;

let m = new measureText('20px Arial');

m.width('哈哈哈啦啦啦啦sdfsda123'); //232.294921875

m.width('哈哈...'); //56.669921875

m.cutByWidth('哈哈哈哈啦啦啦',60,'...')//哈哈...

m.setFont('13px PingFangSC-Regular');

m.width('哈哈哈') //39

m.calcFontSize(60,'胜多负少',{fontSize:14,fontFamily:'Arial'})//获得能放在容器宽度为60的字体大小
1.1.0

6 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago