Skip to content

Commit

Permalink
Add woff2-Support
Browse files Browse the repository at this point in the history
Since newer Versions of Firefox use woff and try to get them, this adds
more and more 404s to server logs.

Closes: #3
  • Loading branch information
campino2k authored and neverpanic committed Jul 21, 2015
1 parent c839b01 commit 4c6b08f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -38,11 +38,11 @@ the terms.
<dd>Download the specified set of webfont formats from Google's servers.
<code>FORMAT</code> is a comma-separated list of identifiers for
webfont formats. Supported identifiers are <code>eof</code>,
<code>woff</code>, <code>svg</code>, and <code>ttf</code>.
Additionally, the special value <code>all</code> expands to all
supported formats. The default is <code>all</code>. Note that you may
not really need all formats. In most cases, WOFF is enough. See
http://caniuse.com/#search=woff for a current status.</dd>
<code>woff</code>, <code>woff2</code>, <code>svg</code>, and
<code>ttf</code>. Additionally, the special value <code>all</code>
expands to all supported formats. The default is <code>all</code>. Note
that you may not really need all formats. In most cases, WOFF is enough.
See http://caniuse.com/#search=woff for a current status.</dd>
<dt><code>-h</code>, <code>--help</code></dt>
<dd>Display this message and exit.</dd>
<dt><code>-l LANGSPEC</code>, <code>--languages=LANGSPEC</code></dt>
Expand Down
21 changes: 13 additions & 8 deletions google-font-download
Expand Up @@ -62,12 +62,12 @@ usage() {
-f FORMAT, --format=FORMAT
Download the specified set of webfont formats from Google's
servers. FORMAT is a comma-separated list of identifiers for
webfont formats. Supported identifiers are eof, woff, svg,
and ttf. Additionally, the special value \`all' expands to
all supported formats. The default is \`$format'. Note that
you may not really need all formats. In most cases, WOFF is
enough. See http://caniuse.com/#search=woff for a current
status.
webfont formats. Supported identifiers are eof, woff, woff2,
svg, and ttf. Additionally, the special value \`all' expands
to all supported formats. The default is \`$format'. Note
that you may not really need all formats. In most cases,
WOFF is enough. See http://caniuse.com/#search=woff for
a current status.
-h, --help
Display this message and exit.
Expand Down Expand Up @@ -198,12 +198,12 @@ fi
declare -a formats
if [ "$format" = "all" ]; then
# Deal with the special "all" value
formats=("eot" "woff" "svg" "ttf")
formats=("eot" "woff" "woff2" "svg" "ttf")
else
IFS=', ' read -a formats <<< "$format"
for f in "${formats[@]}"; do
case "$f" in
eof|woff|svg|ttf)
eof|woff|woff2|svg|ttf)
;;
*)
err_exit "Unsupported font format \`${f}'"
Expand Down Expand Up @@ -247,6 +247,8 @@ useragent[eot]='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)'
# shellcheck disable=SC2154
useragent[woff]='Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0'
# shellcheck disable=SC2154
useragent[woff2]='Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0'
# shellcheck disable=SC2154
useragent[svg]='Mozilla/4.0 (iPad; CPU OS 4_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/4.1 Mobile/9A405 Safari/7534.48.3'
# shellcheck disable=SC2154
useragent[ttf]='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.54.16 (KHTML, like Gecko) Version/5.1.4 Safari/534.54.16'
Expand Down Expand Up @@ -351,6 +353,9 @@ for family in "${families[@]}"; do
woff)
printf >>"$css" "\t\turl('%s') format('woff')%s\n" "${fontnameescaped}.$uakey" "${terminator}"
;;
woff2)
printf >>"$css" "\t\turl('%s') format('woff2')%s\n" "${fontnameescaped}.$uakey" "${terminator}"
;;
ttf)
printf >>"$css" "\t\turl('%s') format('truetype')%s\n" "${fontnameescaped}.$uakey" "${terminator}"
;;
Expand Down

0 comments on commit 4c6b08f

Please sign in to comment.