diff --git a/README.md b/README.md
index 699a4dc..5bd211c 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,13 @@ the terms.
Write the generated CSS into OUTPUT
. The file will be
overwritten and will be created if it doesn't exist. The default is
font.css
.
+ -b BASEPATH
, --base-path=BASEPATH
+ Prepend the base path to the font name. For example,
+ --base-path="https://example.com/fonts/"
will output in
+ font.css
: url('https://example.com/fonts/FONT-NAME.woff2')
.
+
### Positional Arguments
This script accepts an arbitrary number of font specs. A font spec consists
of a font name as accepted by Google's servers, optionally followed by
diff --git a/google-font-download b/google-font-download
index bd3399f..4ee5bb5 100755
--- a/google-font-download
+++ b/google-font-download
@@ -49,6 +49,7 @@ lang="latin"
format="all"
url="https://fonts.googleapis.com/css"
urlref=""
+basepath=""
# Usage message
usage() {
@@ -94,6 +95,11 @@ usage() {
overwritten and will be created if it doesn't exist. The
default is \`$css'.
+ -b BASEPATH, --base-path=BASEPATH
+ Prepend the base path to the font name. For example,
+ --base-path="https://example.com/fonts/" will output in
+ font.css: url('https://example.com/fonts/FONT-NAME.woff2').
+
POSITIONAL ARGUMENTS
This script accepts an arbitrary number of font specs. A font
spec is any string that Google's servers will accept as
@@ -146,7 +152,7 @@ fi
# Parse options
if [ $modern_getopt -eq 1 ]; then
ret=0
- temp=$(getopt -o u:f:hl:o: --long url:,format:,help,languages:,output: -n "${0:-google-font-download}" -- "$@") || ret=$?
+ temp=$(getopt -o u:f:hl:o:b: --long url:,format:,help,languages:,output:,base-path: -n "${0:-google-font-download}" -- "$@") || ret=$?
if [ $ret -ne 0 ]; then
echo >&2
usage
@@ -166,7 +172,7 @@ else
ret=0
# shellcheck disable=SC2048,SC2086
- temp=$(getopt u:f:hl:o: $*) || ret=$?
+ temp=$(getopt u:f:hl:o:b: $*) || ret=$?
if [ $ret -ne 0 ]; then
echo >&2
usage
@@ -199,6 +205,10 @@ while true; do
css=$2
shift 2
;;
+ -b|--base-path)
+ basepath=$2
+ shift 2
+ ;;
--)
shift
break
@@ -467,19 +477,19 @@ for family in "${families[@]}"; do
# Generate the CSS statements required to include the downloaded file.
case "$uakey" in
eot)
- printf >>"$css" "\\t\\turl('%s?#iefix') format('embedded-opentype')%s\\n" "${fontnameescaped}.$uakey" "${terminator}"
+ printf >>"$css" "\\t\\turl('%s%s?#iefix') format('embedded-opentype')%s\\n" "$basepath" "${fontnameescaped}.$uakey" "${terminator}"
;;
woff)
- printf >>"$css" "\\t\\turl('%s') format('woff')%s\\n" "${fontnameescaped}.$uakey" "${terminator}"
+ printf >>"$css" "\\t\\turl('%s%s') format('woff')%s\\n" "$basepath" "${fontnameescaped}.$uakey" "${terminator}"
;;
woff2)
- printf >>"$css" "\\t\\turl('%s') format('woff2')%s\\n" "${fontnameescaped}.$uakey" "${terminator}"
+ printf >>"$css" "\\t\\turl('%s%s') format('woff2')%s\\n" "$basepath" "${fontnameescaped}.$uakey" "${terminator}"
;;
ttf)
- printf >>"$css" "\\t\\turl('%s') format('truetype')%s\\n" "${fontnameescaped}.$uakey" "${terminator}"
+ printf >>"$css" "\\t\\turl('%s%s') format('truetype')%s\\n" "$basepath" "${fontnameescaped}.$uakey" "${terminator}"
;;
svg)
- printf >>"$css" "\\t\\turl('%s#%s') format('svg')%s\\n" "${fontnameescaped}.${uakey}" "$svgname" "${terminator}"
+ printf >>"$css" "\\t\\turl('%s%s#%s') format('svg')%s\\n" "$basepath" "${fontnameescaped}.${uakey}" "$svgname" "${terminator}"
;;
esac
done