Last active
August 25, 2020 03:34
-
-
Save michaelrhodes/b9fe84f2f7aa4db0d536a432091b70e9 to your computer and use it in GitHub Desktop.
click the bookmarklet, then click the text whose font-family you wish to detect
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
javascript:onclick=function(t){return%20onclick=t.preventDefault(),alert(function(t){if(t){for(var%20e=document.createElement("span"),i=document.createElement("canvas"),n=i.getContext("2d"),l="",o=33;o<127;)l+=String.fromCharCode(o++);var%20a=getComputedStyle(t),c=[a.fontStyle,a.fontWeight,"16px/1"],h=a.fontFamily.split(/\s*,\s*/);e.style.font=c.concat(a.fontFamily).join("%20"),e.style.position="absolute",e.style.visibility="hidden",e.textContent=l,document.body.appendChild(e);var%20d,r,g=e.getBoundingClientRect();i.height=g.height,i.width=g.width,n.textAlign="left",n.textBaseline="top";for(var%20f,m=h.length;m--;)n.font=c.concat(h.slice(m).join(",")).join("%20"),n.fillStyle="white",n.fillRect(0,0,g.width,g.height),n.fillStyle="black",n.fillText(l,0,0),n.getImageData(0,0,g.width,g.height),(d=h.join.call(n.getImageData(0,0,g.width,g.height).data,""))!==r&&(f=h[m],r=d);return%20document.body.removeChild(e),f&&f.replace(/["']/g,"")}}(t.target))}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment