Skip to content

The only downloader you need. 下载器的集大成者。

fix: font fallback

XiaoYouChR05df9afc4256
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index 65269365..b2917d98 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -80,12 +80,8 @@ def startApp(application, isSilent=False):
sys.excepthook = exceptionHook
- families = [application.font().defaultFamily()]
- if sys.platform == "darwin":
- families.append("PingFang SC")
- elif sys.platform == "win32":
- families.append("Microsoft YaHei UI")
- cfg.set(cfg.fontFamilies, families, save=False)
+ from app.platform.desktop import buildFontFamilies
+ cfg.set(cfg.fontFamilies, buildFontFamilies(cfg.language.value.value, application.font().defaultFamily()), save=False)
application.setQuitOnLastWindowClosed(False)
if sys.platform == "darwin":
diff --git a/app/platform/desktop.py b/app/platform/desktop.py
index eeb20dc9..75cad8be 100644
--- a/app/platform/desktop.py
+++ b/app/platform/desktop.py
@@ -4,12 +4,48 @@ import sys
from os import PathLike
from pathlib import Path
-from PySide6.QtCore import QMimeData, QProcess, QUrl, Qt
+from PySide6.QtCore import QLocale, QMimeData, QProcess, QUrl, Qt
from PySide6.QtGui import QDesktopServices, QDrag
from PySide6.QtWidgets import QApplication, QWidget
from loguru import logger
+def buildFontFamilies(locale: QLocale, defaultFamily: str) -> list[str]:
+ script = locale.script() if locale.script() != QLocale.Script.AnyScript else QLocale.system().script()
+
+ if sys.platform == "darwin":
+ CJK_CHAINS = {
+ QLocale.Script.TraditionalHanScript: [
+ "PingFang TC", "PingFang SC", "Hiragino Sans", "Apple SD Gothic Neo",
+ ],
+ QLocale.Script.JapaneseScript: [
+ "Hiragino Sans", "PingFang SC", "PingFang TC", "Apple SD Gothic Neo",
+ ],
+ QLocale.Script.KoreanScript: [
+ "Apple SD Gothic Neo", "PingFang SC", "PingFang TC", "Hiragino Sans",
+ ],
+ }
+ DEFAULT_CHAIN = ["PingFang SC", "PingFang TC", "Hiragino Sans", "Apple SD Gothic Neo"]
+ return [defaultFamily] + CJK_CHAINS.get(script, DEFAULT_CHAIN)
+
+ if sys.platform == "win32":
+ CJK_CHAINS = {
+ QLocale.Script.TraditionalHanScript: [
+ "Microsoft JhengHei UI", "Microsoft YaHei UI", "Yu Gothic UI", "Malgun Gothic",
+ ],
+ QLocale.Script.JapaneseScript: [
+ "Yu Gothic UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic",
+ ],
+ QLocale.Script.KoreanScript: [
+ "Malgun Gothic", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Yu Gothic UI",
+ ],
+ }
+ DEFAULT_CHAIN = ["Microsoft YaHei UI", "Microsoft JhengHei UI", "Yu Gothic UI", "Malgun Gothic"]
+ return ["Segoe UI"] + CJK_CHAINS.get(script, DEFAULT_CHAIN)
+
+ return [defaultFamily]
+
+
def _sendForegroundInput() -> None:
# https://github.com/microsoft/PowerToys/pull/14383
"""Send a zero-effect mouse input so Windows grants us foreground rights."""