Tool to measure font's character width, height and descent
To use tool go to this link fontometer
or install it on your computer and run it
git clone https://github.com/danziamo/fontometer.git
npm run build
npm run serve
fontometer
allows use to measure Google Font text.
This tool generates a javascript file with export module name as a font name.
Each exports return javascript function returns height, width and descent of a given text
You can specify one or several font names using |
as a delimiter
After some time fonotometer will apply this font and you can see how it looks like
By pressing Not feelink lucky
button it will generate Javascript file with functions as Font names. Each function name has a measurement for default ASCII symbols. You can download either normal or minified version
Example of downloaded fonts.js
exports['IndieFlower'] = function () {
...
return function (fontSize) {
...
return {
getHeight: function () {
return ratio * height;
},
getDescent: function () {
return ratio * descent;
},
getWidth: getWidth
};
}
}
exports['StalinistOne'] = function () {
...
return function (fontSize) {
...
return {
getHeight: function () {
return ratio * height;
},
getDescent: function () {
return ratio * descent;
},
getWidth: getWidth
};
}
}
After that you can require fonts measurements
const fontMeasureStalinist = require('./fonts').StalinistOne();
const fontMeasureIndie = require('./fonts').IndieFlower();
const fontSize = 32;
const text = 'Hello World!';
const fms = fontMeasureStalinist(fontSize);
console.log(fms.getWidth(text), fms.getHeight(), fms.getDescent());
getWidth
returns width of a given text
getHeight
returns the height of the biggest character in a font
getDescent
returns the height of the biggest descent of a character in a font