Created
June 28, 2025 00:09
-
-
Save apacheli/0f1a31485532bc6cb1a419844ab86ab6 to your computer and use it in GitHub Desktop.
Get only certain characters from Google fonts
This file contains hidden or 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 encode(str) { | |
return ( | |
encodeURIComponent(str) | |
.replace( | |
/[\-\_\.\!\~\*\'\(\)]/g, | |
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, | |
) | |
); | |
} | |
const f = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; | |
const b = `https://fonts.googleapis.com/css2?family=Sniglet&text=${encode(f)}`; | |
console.log(b); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment