Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow local font names to be missing #25

Merged
merged 2 commits into from
Jun 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.css
*.woff2
*.woff
*.eot
*.svg
*.ttf
9 changes: 2 additions & 7 deletions google-font-download
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,10 @@ for family in "${families[@]}"; do

# Determine the local names for the given fonts so we can use a locally-installed font if available.
css_src_string=$(echo "$css_string" | grep "src:")
ret=0
local_name=$(echo "$css_src_string" | grep -Eo "src: local\\('[^']+'\\)," | $ESED "s/^src: local\\('([^']+)'\\),$/\\1/g") || ret=$?
if [ $ret -ne 0 ]; then
errors=1
printf >&2 "Failed to determine local font name\\n"
fi
local_name=$(echo "$css_src_string" | grep -Eo "src: local\\('[^']+'\\)," | $ESED "s/^src: local\\('([^']+)'\\),$/\\1/g") || true
local_postscript_name=$(echo "$css_src_string" | grep -Eo ", local\\('[^']+'\\)," | $ESED "s/^, local\\('([^']+)'\\),$/\\1/g") || true

# When the local font name couldn't be determined, still produce a valid CSS file
# Some fonts don't have a local font name
if [ -n "$local_name" ]; then
printf >>"$css" "\\t\\tlocal('%s'),\\n" "$local_name"
fi
Expand Down