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

Source Arabic font from CDN, newer repo #5053

Open
wants to merge 1 commit 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
25 changes: 18 additions & 7 deletions scripts/get-fonts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# This script downloads several Noto fonts from https://github.com/notofonts/noto-fonts
# That repo was archived in 2023 and is no longer updated.
# Additional fonts can be found on https://notofonts.github.io
# Fonts in the NEWER_REPO list are downloaded from Noto's CDN or individual repos.

import os
import requests
Expand All @@ -17,13 +17,19 @@
except FileExistsError:
warnings.warn("Font directory already exists")

# Fonts to source from CDN linked by https://notofonts.github.io
# Includes updates after 2023.
NEWER_REPO = [
"NotoSansArabic",
]

# Fonts to download in regular, bold, and italic
REGULAR_BOLD_ITALIC = ["NotoSans"]

# Fonts to download in regular and bold
REGULAR_BOLD = [
"NotoSansAdlamUnjoined",
"NotoSansArabicUI",
"NotoSansArabic",
"NotoSansArmenian",
"NotoSansBalinese",
"NotoSansBamum",
Expand Down Expand Up @@ -90,13 +96,18 @@
"NotoSansYi",
]


# Attempt to download the font from repos in this order
def findFontUrls(fontName, modifier):
return [
f"https://github.com/notofonts/noto-fonts/raw/main/hinted/ttf/{fontName}/{fontName}-{modifier}.ttf",
# currently only sourcing from one repo
]
if fontName in NEWER_REPO:
subDir = fontName.replace("NotoSans", "").replace("UI", "").lower()
return [
f"https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/{fontName}/hinted/ttf/{fontName}-{modifier}.ttf",
f"https://notofonts.github.io/{subDir}/fonts/{fontName}/hinted/ttf/{fontName}-{modifier}.ttf",
]
else:
return [
f"https://github.com/notofonts/noto-fonts/raw/main/hinted/ttf/{fontName}/{fontName}-{modifier}.ttf",
]


def downloadToFile(urls, destination, dir=FONTDIR):
Expand Down
4 changes: 2 additions & 2 deletions style/fonts.mss
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ A regular style.
*/
@book-fonts: "Noto Sans Regular",
"Noto Sans Adlam Unjoined Regular",
"Noto Sans Arabic UI Regular",
"Noto Sans Arabic Regular",
"Noto Sans Armenian Regular",
"Noto Sans Balinese Regular",
"Noto Sans Bamum Regular",
Expand Down Expand Up @@ -129,7 +129,7 @@ regular text and can be used for emphasis. Fallback is a regular style.
*/
@bold-fonts: "Noto Sans Bold",
"Noto Sans Adlam Unjoined Bold",
"Noto Sans Arabic UI Bold",
"Noto Sans Arabic Bold",
"Noto Sans Armenian Bold",
"Noto Sans Balinese Bold",
"Noto Sans Bamum Bold",
Expand Down