https://github.com/pana/textwidth
Calculator of text width.
https://github.com/pana/textwidth
Last synced: 7 months ago
JSON representation
Calculator of text width.
- Host: GitHub
- URL: https://github.com/pana/textwidth
- Owner: Pana
- License: mit
- Created: 2013-11-27T06:36:45.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-26T00:16:35.000Z (over 11 years ago)
- Last Synced: 2025-01-28T21:47:16.906Z (8 months ago)
- Language: JavaScript
- Size: 148 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
TextWidth
=========
Calculate text width use canvas measureText() method.## Install
npm install textwidth## Example
```
var tw = require('textwidth');
// 使用默认字体及大小
var width = tw("Hello textwidth!!!")
// 设置字体,大小
var width = tw("Set the text font", "10px Arial")
```## Doc
## Test
## Todo
* 添加测试用例
* 完善文档
* 发布到npm## Bug
* 中文字体宽度偏差
## Roadmap
* 计算高度
* 根据不同的单位(pixel, pm)计算宽度
* 允许设置字间距## 其他实现方式
## License
MIT