Skip to content

Instantly share code, notes, and snippets.

@mixu
Created June 20, 2017 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mixu/ce81f4950e8ade0d036f5a499e4e9a5f to your computer and use it in GitHub Desktop.
Save mixu/ce81f4950e8ade0d036f5a499e4e9a5f to your computer and use it in GitHub Desktop.
(function() {
function range(start,stop) {
var result=[];
for (var idx=start.charCodeAt(0),end=stop.charCodeAt(0); idx <=end; ++idx){
result.push(String.fromCharCode(idx));
}
return result;
};
let glyphWidths = {};
range('!', '~').forEach((char) => {
const e = document.createElement('span');
e.style.fontSize = '13px';
e.style.fontFamily = 'Camphor';
e.innerHTML = char;
document.body.appendChild(e);
const width = e.offsetWidth;
document.body.removeChild(e);
glyphWidths[char] = width;
});
console.log(glyphWidths);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment