Skip to content

Commit 0c4c110

Browse files
committed
fix: use urlopen with User-Agent and BytesIO for Poppins font download
1 parent a5d786c commit 0c4c110

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

.github/scripts/generate_showcase.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ def main():
151151
try:
152152
# Try to get a system font or download one
153153
url = "https://github.com/google/fonts/raw/main/ofl/poppins/Poppins-Bold.ttf"
154-
urllib.request.urlretrieve(url, "Poppins-Bold.ttf")
155-
font = ImageFont.truetype("Poppins-Bold.ttf", 120)
154+
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
155+
font_bytes = BytesIO(urllib.request.urlopen(req).read())
156+
font = ImageFont.truetype(font_bytes, 120)
156157
except Exception:
157158
font = ImageFont.load_default()
158159

0 commit comments

Comments
 (0)