Skip to content

Commit b560368

Browse files
authored
Merge pull request #7418 from plotly/fix-font-redirects-ci
Update font URLs and add additional error handling
2 parents 8e2a5d7 + 14bc2e6 commit b560368

30 files changed

+60
-75
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
install-firefox: false
4545
install-geckodriver: false
4646
install-chrome: true
47-
chrome-version: "127.0.6533.119"
47+
chrome-version: "132.0.6834.110"
4848
- attach_workspace:
4949
at: ~/
5050
- run:
@@ -83,7 +83,7 @@ jobs:
8383
install-firefox: false
8484
install-geckodriver: false
8585
install-chrome: true
86-
chrome-version: "127.0.6533.119"
86+
chrome-version: "132.0.6834.110"
8787
- attach_workspace:
8888
at: ~/
8989
- run:
@@ -105,7 +105,7 @@ jobs:
105105
install-firefox: false
106106
install-geckodriver: false
107107
install-chrome: true
108-
chrome-version: "127.0.6533.119"
108+
chrome-version: "132.0.6834.110"
109109
- attach_workspace:
110110
at: ~/
111111
- run:
@@ -127,7 +127,7 @@ jobs:
127127
install-firefox: false
128128
install-geckodriver: false
129129
install-chrome: true
130-
chrome-version: "127.0.6533.119"
130+
chrome-version: "132.0.6834.110"
131131
- attach_workspace:
132132
at: ~/
133133
- run:
@@ -168,7 +168,7 @@ jobs:
168168
install-firefox: false
169169
install-geckodriver: false
170170
install-chrome: true
171-
chrome-version: "127.0.6533.119"
171+
chrome-version: "132.0.6834.110"
172172
- attach_workspace:
173173
at: ~/
174174
- run:
@@ -189,7 +189,7 @@ jobs:
189189
install-firefox: false
190190
install-geckodriver: false
191191
install-chrome: true
192-
chrome-version: "127.0.6533.119"
192+
chrome-version: "132.0.6834.110"
193193
- attach_workspace:
194194
at: ~/
195195
- run:

.circleci/download_google_fonts.py

Lines changed: 49 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,82 @@
1+
import os
2+
13
import requests
24

3-
dirOut = '.circleci/fonts/truetype/googleFonts/'
5+
dir_out = ".circleci/fonts/truetype/googleFonts/"
6+
47

5-
def download(repo, family, types):
6-
for t in types :
7-
name = family + t + '.ttf'
8-
url = repo + name + '?raw=true'
9-
print(url)
10-
req = requests.get(url, allow_redirects=True)
8+
def download(repo, family, types, overwrite=True):
9+
for t in types:
10+
name = family + t + ".ttf"
11+
url = repo + name + "?raw=true"
12+
out_file = dir_out + name
13+
print("Getting: ", url)
14+
if os.path.exists(out_file) and not overwrite:
15+
print(" => Already exists: ", out_file)
16+
continue
17+
req = requests.get(url, allow_redirects=False)
1118
if req.status_code != 200:
19+
# If we get a redirect, print an error so that we know to update the URL
20+
if req.status_code == 302 or req.status_code == 301:
21+
new_url = req.headers.get("Location")
22+
print(f" => Redirected -- please update URL to: {new_url}")
1223
raise RuntimeError(f"""
1324
Download failed.
1425
Status code: {req.status_code}
1526
Message: {req.reason}
16-
"""
17-
)
18-
open(dirOut + name, 'wb').write(req.content)
27+
""")
28+
open(out_file, "wb").write(req.content)
29+
1930

2031
download(
21-
'https://github.com/googlefonts/noto-fonts/blob/main/hinted/ttf/NotoSansMono/',
22-
'NotoSansMono',
23-
[
24-
'-Regular',
25-
'-Bold'
26-
]
32+
"https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSansMono/hinted/ttf/",
33+
"NotoSansMono",
34+
["-Regular", "-Bold"],
2735
)
2836

2937
download(
30-
'https://github.com/googlefonts/noto-fonts/blob/main/hinted/ttf/NotoSans/',
31-
'NotoSans',
32-
[
33-
'-Regular',
34-
'-Italic',
35-
'-Bold'
36-
]
38+
"https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSans/hinted/ttf/",
39+
"NotoSans",
40+
["-Regular", "-Italic", "-Bold"],
3741
)
3842

3943
download(
40-
'https://github.com/googlefonts/noto-fonts/blob/main/hinted/ttf/NotoSerif/',
41-
'NotoSerif',
44+
"https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSerif/hinted/ttf/",
45+
"NotoSerif",
4246
[
43-
'-Regular',
44-
'-Italic',
45-
'-Bold',
46-
'-BoldItalic',
47-
]
47+
"-Regular",
48+
"-Italic",
49+
"-Bold",
50+
"-BoldItalic",
51+
],
4852
)
4953

5054
download(
51-
'https://github.com/google/fonts/blob/main/ofl/oldstandardtt/',
52-
'OldStandard',
53-
[
54-
'-Regular',
55-
'-Italic',
56-
'-Bold'
57-
]
55+
"https://raw.githubusercontent.com/google/fonts/refs/heads/main/ofl/oldstandardtt/",
56+
"OldStandard",
57+
["-Regular", "-Italic", "-Bold"],
5858
)
5959

6060
download(
61-
'https://github.com/google/fonts/blob/main/ofl/ptsansnarrow/',
62-
'PT_Sans-Narrow-Web',
63-
[
64-
'-Regular',
65-
'-Bold'
66-
]
61+
"https://raw.githubusercontent.com/google/fonts/refs/heads/main/ofl/ptsansnarrow/",
62+
"PT_Sans-Narrow-Web",
63+
["-Regular", "-Bold"],
6764
)
6865

6966
download(
70-
'https://github.com/impallari/Raleway/blob/master/fonts/v3.000%20Fontlab/TTF/',
71-
'Raleway',
72-
[
73-
'-Regular',
74-
'-Regular-Italic',
75-
'-Bold',
76-
'-Bold-Italic'
77-
]
67+
"https://raw.githubusercontent.com/impallari/Raleway/refs/heads/master/fonts/v3.000%20Fontlab/TTF/",
68+
"Raleway",
69+
["-Regular", "-Regular-Italic", "-Bold", "-Bold-Italic"],
7870
)
7971

8072
download(
81-
'https://github.com/googlefonts/roboto/blob/main/src/hinted/',
82-
'Roboto',
83-
[
84-
'-Regular',
85-
'-Italic',
86-
'-Bold',
87-
'-BoldItalic'
88-
]
73+
"https://raw.githubusercontent.com/googlefonts/roboto-2/refs/heads/main/src/hinted/",
74+
"Roboto",
75+
["-Regular", "-Italic", "-Bold", "-BoldItalic"],
8976
)
9077

9178
download(
92-
'https://github.com/expo/google-fonts/blob/main/font-packages/gravitas-one/400Regular/',
93-
'GravitasOne',
94-
[
95-
'_400Regular'
96-
]
79+
"https://raw.githubusercontent.com/expo/google-fonts/refs/heads/main/font-packages/gravitas-one/400Regular/",
80+
"GravitasOne",
81+
["_400Regular"],
9782
)

.circleci/env_image.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/sh
2+
set -e
23
# install required fonts
3-
sudo apt-get install fonts-liberation2 fonts-open-sans fonts-noto-cjk fonts-noto-color-emoji && \
4-
sudo python3 .circleci/download_google_fonts.py && \
5-
sudo cp -r .circleci/fonts/ /usr/share/ && \
6-
sudo fc-cache -f && \
4+
sudo apt-get install fonts-liberation2 fonts-open-sans fonts-noto-cjk fonts-noto-color-emoji
5+
sudo python3 .circleci/download_google_fonts.py
6+
sudo cp -r .circleci/fonts/ /usr/share/
7+
sudo fc-cache -f
78
# install kaleido & plotly
89
sudo python3 -m pip install kaleido==0.2.1 plotly==5.5.0 --progress-bar off
910
# install numpy i.e. to convert arrays to typed arrays

.circleci/fonts/truetype/googleFonts/.gitignore

Lines changed: 0 additions & 1 deletion
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.

test/image/baselines/fonts.png

-38 Bytes
Loading

test/image/baselines/gl2d_fonts.png

-38 Bytes
Loading
1.84 KB
Loading

0 commit comments

Comments
 (0)