Skip to content

Instantly share code, notes, and snippets.

@apacheli
Created June 28, 2025 00:09
Show Gist options
  • Save apacheli/0f1a31485532bc6cb1a419844ab86ab6 to your computer and use it in GitHub Desktop.
Save apacheli/0f1a31485532bc6cb1a419844ab86ab6 to your computer and use it in GitHub Desktop.
Get only certain characters from Google fonts
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