0.0.0 • Published 13 years ago
char-size v0.0.0
char-size
return the size in pixels of a single character
This is useful for writing column-sensitive wrapping code, particularly for fixed-width fonts.
example
var charSize = require('char-size');
var size = charSize(document.body);
console.log(size.width + 'x' + size.height);compile the example and open it in a browser:
$ echo '<html><body><script src="bundle.js"></script></body></html>' > index.html
$ browserify size.js > bundle.js
$ xdg-open index.htmlin the browser console you'll see:
8x20methods
var charSize = require('char-size')var size = charSize(opts)
Return the size of the opts.chr or 'x' character at opts.target or
document.body. The size.width and size.height will be integers in pixels.
If opts is a dom element, use it as the opts.target value.
install
With npm do:
npm install char-sizelicense
MIT
0.0.0
13 years ago
