Created
June 20, 2017 20:30
-
-
Save mixu/ce81f4950e8ade0d036f5a499e4e9a5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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