-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Update font URLs and add additional error handling #7418
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
f50a7cd
904bfe1
16a4a0f
ff831b2
6c85949
71a4d77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,82 @@ | ||
import os | ||
|
||
import requests | ||
|
||
dirOut = '.circleci/fonts/truetype/googleFonts/' | ||
dir_out = ".circleci/fonts/truetype/googleFonts/" | ||
|
||
|
||
def download(repo, family, types): | ||
for t in types : | ||
name = family + t + '.ttf' | ||
url = repo + name + '?raw=true' | ||
print(url) | ||
req = requests.get(url, allow_redirects=True) | ||
for t in types: | ||
name = family + t + ".ttf" | ||
url = repo + name + "?raw=true" | ||
outfile = dir_out + name | ||
print("Getting: ", url) | ||
if os.path.exists(outfile): | ||
print(" => Already exists: ", outfile) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rather than overwrite (I don't know how often font files themselves update)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this instead of removing the download step from the CI; in other words, the download script will still run but it will not actually attempt to download the fonts because they are already in the repo. I could alternatively modify the script to overwrite, and remove the step that runs the script from the CI. I liked this approach though because it's easier to revert if we change our minds about keeping the fonts in the repo. I don't think we're worried about the font files being updated all that often... if we were I wouldn't want to put them in the repo. |
||
continue | ||
req = requests.get(url, allow_redirects=False) | ||
if req.status_code != 200: | ||
# If we get a redirect, print an error so that we know to update the URL | ||
if req.status_code == 302 or req.status_code == 301: | ||
new_url = req.headers.get("Location") | ||
print(f" => Redirected -- please update URL to: {new_url}") | ||
raise RuntimeError(f""" | ||
Download failed. | ||
Status code: {req.status_code} | ||
Message: {req.reason} | ||
""" | ||
) | ||
open(dirOut + name, 'wb').write(req.content) | ||
""") | ||
open(outfile, "wb").write(req.content) | ||
|
||
|
||
download( | ||
'https://github.com/googlefonts/noto-fonts/blob/main/hinted/ttf/NotoSansMono/', | ||
'NotoSansMono', | ||
[ | ||
'-Regular', | ||
'-Bold' | ||
] | ||
"https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSansMono/hinted/ttf/", | ||
"NotoSansMono", | ||
["-Regular", "-Bold"], | ||
) | ||
|
||
download( | ||
'https://github.com/googlefonts/noto-fonts/blob/main/hinted/ttf/NotoSans/', | ||
'NotoSans', | ||
[ | ||
'-Regular', | ||
'-Italic', | ||
'-Bold' | ||
] | ||
"https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSans/hinted/ttf/", | ||
"NotoSans", | ||
["-Regular", "-Italic", "-Bold"], | ||
) | ||
|
||
download( | ||
'https://github.com/googlefonts/noto-fonts/blob/main/hinted/ttf/NotoSerif/', | ||
'NotoSerif', | ||
"https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSerif/hinted/ttf/", | ||
"NotoSerif", | ||
[ | ||
'-Regular', | ||
'-Italic', | ||
'-Bold', | ||
'-BoldItalic', | ||
] | ||
"-Regular", | ||
"-Italic", | ||
"-Bold", | ||
"-BoldItalic", | ||
], | ||
) | ||
|
||
download( | ||
'https://github.com/google/fonts/blob/main/ofl/oldstandardtt/', | ||
'OldStandard', | ||
[ | ||
'-Regular', | ||
'-Italic', | ||
'-Bold' | ||
] | ||
"https://raw.githubusercontent.com/google/fonts/refs/heads/main/ofl/oldstandardtt/", | ||
"OldStandard", | ||
["-Regular", "-Italic", "-Bold"], | ||
) | ||
|
||
download( | ||
'https://github.com/google/fonts/blob/main/ofl/ptsansnarrow/', | ||
'PT_Sans-Narrow-Web', | ||
[ | ||
'-Regular', | ||
'-Bold' | ||
] | ||
"https://raw.githubusercontent.com/google/fonts/refs/heads/main/ofl/ptsansnarrow/", | ||
"PT_Sans-Narrow-Web", | ||
["-Regular", "-Bold"], | ||
) | ||
|
||
download( | ||
'https://github.com/impallari/Raleway/blob/master/fonts/v3.000%20Fontlab/TTF/', | ||
'Raleway', | ||
[ | ||
'-Regular', | ||
'-Regular-Italic', | ||
'-Bold', | ||
'-Bold-Italic' | ||
] | ||
"https://raw.githubusercontent.com/impallari/Raleway/refs/heads/master/fonts/v3.000%20Fontlab/TTF/", | ||
"Raleway", | ||
["-Regular", "-Regular-Italic", "-Bold", "-Bold-Italic"], | ||
) | ||
|
||
download( | ||
'https://github.com/googlefonts/roboto/blob/main/src/hinted/', | ||
'Roboto', | ||
[ | ||
'-Regular', | ||
'-Italic', | ||
'-Bold', | ||
'-BoldItalic' | ||
] | ||
"https://raw.githubusercontent.com/googlefonts/roboto-2/refs/heads/main/src/hinted/", | ||
"Roboto", | ||
["-Regular", "-Italic", "-Bold", "-BoldItalic"], | ||
) | ||
|
||
download( | ||
'https://github.com/expo/google-fonts/blob/main/font-packages/gravitas-one/400Regular/', | ||
'GravitasOne', | ||
[ | ||
'_400Regular' | ||
] | ||
"https://raw.githubusercontent.com/expo/google-fonts/refs/heads/main/font-packages/gravitas-one/400Regular/", | ||
"GravitasOne", | ||
["_400Regular"], | ||
) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI was failing with a message about "Chrome failed to start" and this resolved the issue; in any case, it seems good to keep the Chrome version somewhat up to date.