(lang: str)
| 398 | |
| 399 | |
| 400 | def download_remote_fonts(lang: str): |
| 401 | lang = lang.lower() |
| 402 | LANG_NAME_MAP = { |
| 403 | **{la: "GoNotoKurrent-Regular.ttf" for la in noto_list}, |
| 404 | **{ |
| 405 | la: f"SourceHanSerif{region}-Regular.ttf" |
| 406 | for region, langs in { |
| 407 | "CN": ["zh-cn", "zh-hans", "zh"], |
| 408 | "TW": ["zh-tw", "zh-hant"], |
| 409 | "JP": ["ja"], |
| 410 | "KR": ["ko"], |
| 411 | }.items() |
| 412 | for la in langs |
| 413 | }, |
| 414 | } |
| 415 | font_name = LANG_NAME_MAP.get(lang, "GoNotoKurrent-Regular.ttf") |
| 416 | |
| 417 | # docker |
| 418 | font_path = ConfigManager.get("NOTO_FONT_PATH", Path("/app", font_name).as_posix()) |
| 419 | if not Path(font_path).exists(): |
| 420 | font_path, _ = get_font_and_metadata(font_name) |
| 421 | font_path = font_path.as_posix() |
| 422 | |
| 423 | logger.info(f"use font: {font_path}") |
| 424 | |
| 425 | return font_path |
no test coverage detected