From 516180e73084ea57bb3350b5dfc5b582f8f15a98 Mon Sep 17 00:00:00 2001 From: jpfluger Date: Sun, 23 Sep 2018 11:11:59 -0500 Subject: [PATCH 1/3] prepend website url to the font name --- README.md | 5 +++++ google-font-download | 24 +++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 699a4dc..6d9b374 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.
+
-w WEBSITE, --website=WEBSITE
+
Prepend the website url to the font name. For example, + --website="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..79a4206 100755 --- a/google-font-download +++ b/google-font-download @@ -49,6 +49,7 @@ lang="latin" format="all" url="https://fonts.googleapis.com/css" urlref="" +website="" # Usage message usage() { @@ -94,6 +95,11 @@ usage() { overwritten and will be created if it doesn't exist. The default is \`$css'. + -w WEBSITE, --website=WEBSITE + Prepend the website url to the font name. For example, + --website="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:w: --long url:,format:,help,languages:,output:,website: -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:w: $*) || ret=$? if [ $ret -ne 0 ]; then echo >&2 usage @@ -199,6 +205,10 @@ while true; do css=$2 shift 2 ;; + -w|--website) + website=$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" "$website" "${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" "$website" "${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" "$website" "${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" "$website" "${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" "$website" "${fontnameescaped}.${uakey}" "$svgname" "${terminator}" ;; esac done From dcd8414db423a8e882f39588d451f7319bf6b182 Mon Sep 17 00:00:00 2001 From: Jaret Pfluger Date: Tue, 23 Oct 2018 23:58:39 -0500 Subject: [PATCH 2/3] updated README changing --website to --base-path --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d9b374..5bd211c 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,9 @@ 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.
-
-w WEBSITE, --website=WEBSITE
-
Prepend the website url to the font name. For example, - --website="https://example.com/fonts/" will output in +
-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').
From 6923802bbef6c7f1ea760faa17c668d1144cfb8b Mon Sep 17 00:00:00 2001 From: Jaret Pfluger Date: Wed, 24 Oct 2018 00:13:12 -0500 Subject: [PATCH 3/3] update --website to --base-path --- google-font-download | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/google-font-download b/google-font-download index 79a4206..4ee5bb5 100755 --- a/google-font-download +++ b/google-font-download @@ -49,7 +49,7 @@ lang="latin" format="all" url="https://fonts.googleapis.com/css" urlref="" -website="" +basepath="" # Usage message usage() { @@ -95,9 +95,9 @@ usage() { overwritten and will be created if it doesn't exist. The default is \`$css'. - -w WEBSITE, --website=WEBSITE - Prepend the website url to the font name. For example, - --website="https://example.com/fonts/" will output in + -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 @@ -152,7 +152,7 @@ fi # Parse options if [ $modern_getopt -eq 1 ]; then ret=0 - temp=$(getopt -o u:f:hl:o:w: --long url:,format:,help,languages:,output:,website: -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 @@ -172,7 +172,7 @@ else ret=0 # shellcheck disable=SC2048,SC2086 - temp=$(getopt u:f:hl:o:w: $*) || ret=$? + temp=$(getopt u:f:hl:o:b: $*) || ret=$? if [ $ret -ne 0 ]; then echo >&2 usage @@ -205,8 +205,8 @@ while true; do css=$2 shift 2 ;; - -w|--website) - website=$2 + -b|--base-path) + basepath=$2 shift 2 ;; --) @@ -477,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%s?#iefix') format('embedded-opentype')%s\\n" "$website" "${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%s') format('woff')%s\\n" "$website" "${fontnameescaped}.$uakey" "${terminator}" + printf >>"$css" "\\t\\turl('%s%s') format('woff')%s\\n" "$basepath" "${fontnameescaped}.$uakey" "${terminator}" ;; woff2) - printf >>"$css" "\\t\\turl('%s%s') format('woff2')%s\\n" "$website" "${fontnameescaped}.$uakey" "${terminator}" + printf >>"$css" "\\t\\turl('%s%s') format('woff2')%s\\n" "$basepath" "${fontnameescaped}.$uakey" "${terminator}" ;; ttf) - printf >>"$css" "\\t\\turl('%s%s') format('truetype')%s\\n" "$website" "${fontnameescaped}.$uakey" "${terminator}" + printf >>"$css" "\\t\\turl('%s%s') format('truetype')%s\\n" "$basepath" "${fontnameescaped}.$uakey" "${terminator}" ;; svg) - printf >>"$css" "\\t\\turl('%s%s#%s') format('svg')%s\\n" "$website" "${fontnameescaped}.${uakey}" "$svgname" "${terminator}" + printf >>"$css" "\\t\\turl('%s%s#%s') format('svg')%s\\n" "$basepath" "${fontnameescaped}.${uakey}" "$svgname" "${terminator}" ;; esac done