Skip to content

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
install-firefox: false
install-geckodriver: false
install-chrome: true
chrome-version: "127.0.6533.119"
chrome-version: "136.0.7103.92"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

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.

- attach_workspace:
at: ~/
- run:
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
install-firefox: false
install-geckodriver: false
install-chrome: true
chrome-version: "127.0.6533.119"
chrome-version: "136.0.7103.92"
- attach_workspace:
at: ~/
- run:
Expand All @@ -105,7 +105,7 @@ jobs:
install-firefox: false
install-geckodriver: false
install-chrome: true
chrome-version: "127.0.6533.119"
chrome-version: "136.0.7103.92"
- attach_workspace:
at: ~/
- run:
Expand All @@ -127,7 +127,7 @@ jobs:
install-firefox: false
install-geckodriver: false
install-chrome: true
chrome-version: "127.0.6533.119"
chrome-version: "136.0.7103.92"
- attach_workspace:
at: ~/
- run:
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
install-firefox: false
install-geckodriver: false
install-chrome: true
chrome-version: "127.0.6533.119"
chrome-version: "136.0.7103.92"
- attach_workspace:
at: ~/
- run:
Expand All @@ -189,7 +189,7 @@ jobs:
install-firefox: false
install-geckodriver: false
install-chrome: true
chrome-version: "127.0.6533.119"
chrome-version: "136.0.7103.92"
- attach_workspace:
at: ~/
- run:
Expand Down
113 changes: 49 additions & 64 deletions .circleci/download_google_fonts.py
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)
def download(repo, family, types, overwrite=True):
for t in types:
name = family + t + ".ttf"
url = repo + name + "?raw=true"
out_file = dir_out + name
print("Getting: ", url)
if os.path.exists(out_file) and not overwrite:
print(" => Already exists: ", out_file)
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(out_file, "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"],
)
9 changes: 5 additions & 4 deletions .circleci/env_image.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/sh
set -e
# install required fonts
sudo apt-get install fonts-liberation2 fonts-open-sans fonts-noto-cjk fonts-noto-color-emoji && \
sudo python3 .circleci/download_google_fonts.py && \
sudo cp -r .circleci/fonts/ /usr/share/ && \
sudo fc-cache -f && \
sudo apt-get install fonts-liberation2 fonts-open-sans fonts-noto-cjk fonts-noto-color-emoji
sudo python3 .circleci/download_google_fonts.py
sudo cp -r .circleci/fonts/ /usr/share/
sudo fc-cache -f
# install kaleido & plotly
sudo python3 -m pip install kaleido==0.2.1 plotly==5.5.0 --progress-bar off
# install numpy i.e. to convert arrays to typed arrays
Expand Down
1 change: 0 additions & 1 deletion .circleci/fonts/truetype/googleFonts/.gitignore

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified test/image/baselines/fonts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_fonts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/map_custom-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.