read mirror from env

This commit is contained in:
subframe7536 2025-01-07 20:57:50 +08:00
parent 9070169744
commit d59773ed02
2 changed files with 5 additions and 6 deletions

View file

@ -8,7 +8,7 @@ import shutil
import time import time
from functools import partial from functools import partial
from multiprocessing import Pool from multiprocessing import Pool
from os import listdir, makedirs, path, remove, walk, getenv from os import environ, listdir, makedirs, path, remove, walk, getenv
from typing import Callable from typing import Callable
from zipfile import ZIP_DEFLATED, ZipFile from zipfile import ZIP_DEFLATED, ZipFile
from fontTools.ttLib import TTFont, newTable from fontTools.ttLib import TTFont, newTable
@ -203,7 +203,7 @@ class FontConfig:
self.use_hinted = True self.use_hinted = True
# whether to enable ligature # whether to enable ligature
self.enable_liga = True self.enable_liga = True
self.github_mirror = "github.com" self.github_mirror = environ.get("GITHUB", "github.com")
self.feature_freeze = { self.feature_freeze = {
"cv01": "ignore", "cv01": "ignore",
"cv02": "ignore", "cv02": "ignore",
@ -568,8 +568,7 @@ def fix_cn_cv(font: TTFont):
feature_record.Feature.LookupListIndex[0] feature_record.Feature.LookupListIndex[0]
].SubTable[0] ].SubTable[0]
sub_table.mapping = { sub_table.mapping = {
value: f"{value}.full" value: f"{value}.full" for value in config[feature_record.FeatureTag]
for value in config[feature_record.FeatureTag]
} }

View file

@ -148,7 +148,7 @@ def check_font_patcher(
shutil.rmtree("FontPatcher", ignore_errors=True) shutil.rmtree("FontPatcher", ignore_errors=True)
zip_path = "FontPatcher.zip" zip_path = "FontPatcher.zip"
url = f"{parse_github_mirror(github_mirror)}/ryanoasis/nerd-fonts/releases/download/v{version}/{zip_path}" url = f"https://{github_mirror}/ryanoasis/nerd-fonts/releases/download/v{version}/{zip_path}"
if not download_zip_and_extract( if not download_zip_and_extract(
name="Nerd Font Patcher", url=url, zip_path=zip_path, output_dir=target_dir name="Nerd Font Patcher", url=url, zip_path=zip_path, output_dir=target_dir
): ):
@ -165,7 +165,7 @@ def check_font_patcher(
def download_cn_base_font( def download_cn_base_font(
tag: str, zip_path: str, target_dir: str, github_mirror: str = "github.com" tag: str, zip_path: str, target_dir: str, github_mirror: str = "github.com"
) -> bool: ) -> bool:
url = f"{parse_github_mirror(github_mirror)}/subframe7536/maple-font/releases/download/{tag}/{zip_path}" url = f"https://{github_mirror}/subframe7536/maple-font/releases/download/{tag}/{zip_path}"
return download_zip_and_extract( return download_zip_and_extract(
name=f"{'Static' if 'static' in zip_path else 'Variable'} CN Base Font", name=f"{'Static' if 'static' in zip_path else 'Variable'} CN Base Font",
url=url, url=url,