So if you have already read my previous post about faviator
{% link https://dev.to/ycmjason/introducing-faviator-a-simple-easy-favicon-generator-32g5
I am very grateful to have received 19 stars (including my own star) on GitHub
This week has been very exciting, I have got a few issues
I heard some feedback regarding the faviator playground. One of which suggests to provide a dropdown to make font style selecting easier.
So I decided to work on this one first.
The Google Font API
https://www.googleapis.com/webfonts/v1/webfonts?key=YOUR-API-KEY
You can generate your own API key here
{
"kind": "webfonts#webfontList",
"items": [
{
"kind": "webfonts#webfont",
"family": "ABeeZee",
"category": "sans-serif",
"variants": [
"regular",
"italic"
],
"subsets": [
"latin"
],
"version": "v11",
"lastModified": "2017-10-10",
"files": {
"regular": "http://fonts.gstatic.com/s/abeezee/v11/mE5BOuZKGln_Ex0uYKpIaw.ttf",
"italic": "http://fonts.gstatic.com/s/abeezee/v11/kpplLynmYgP0YtlJA3atRw.ttf"
}
},
...
]
}
Nice! So we somewhat have all the family names, but I don't want to serve such a large file to my frontend just for the names. So I started writing a script to grab all the font names.
#!/usr/bin/env bash
KEY=$1
echo '['
curl -s "https://www.googleapis.com/webfonts/v1/webfonts?key=$KEY&sort=alpha" | \
sed -n 's/ *"family": "\(.*\)",/ "\1",/p' | \
sed '$s/\(.*\),/\1/'
echo ']'
Usage:
> bash grepFonts.bash YOUR-API-KEY
[
"ABeeZee",
"Abel",
"Abhaya Libre",
"Abril Fatface",
"Aclonica",
"Acme",
...
"Zeyada",
"Zilla Slab",
"Zilla Slab Highlight"
]
And here we go, no more frustration when selecting text on faviator playground