From 735703aa4cca57eefea9c10e41a5ba01138cddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Fri, 15 Nov 2024 17:32:41 +0800 Subject: [PATCH] font --- py/LunaTranslator/myutils/config.py | 15 +++++++++-- py/files/defaultconfig/static_data.json | 35 +++++++++++++++++-------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/py/LunaTranslator/myutils/config.py b/py/LunaTranslator/myutils/config.py index 19e79727..897d2d5a 100644 --- a/py/LunaTranslator/myutils/config.py +++ b/py/LunaTranslator/myutils/config.py @@ -1,5 +1,5 @@ import json -import os, time, uuid, shutil +import os, time, uuid, shutil, sys from traceback import print_exc from qtsymbols import * @@ -743,7 +743,18 @@ def get_font_default(lang: str, issetting: bool) -> str: l = lang if lang in static_data[t].keys() else "default" font_default = "" - for font in static_data[t][l]: + + if isinstance(static_data[t][l], list): + fontlist = static_data[t][l] + elif isinstance(static_data[t][l], dict): + if tuple(sys.version_info)[:2] == (3, 4): + target = "xp" + else: + target = "normal" + fontlist = static_data[t][l].get(target, []) + else: + fontlist = [] + for font in fontlist: if is_font_installed(font): font_default = font break diff --git a/py/files/defaultconfig/static_data.json b/py/files/defaultconfig/static_data.json index 7f6d6625..4995cf16 100644 --- a/py/files/defaultconfig/static_data.json +++ b/py/files/defaultconfig/static_data.json @@ -309,17 +309,30 @@ "Microsoft Sans Serif", "Arial" ], - "zh": [ - "Microsoft YaHei UI", - "微软雅黑", - "Microsoft YaHei", - "黑体", - "SimHei", - "新宋体", - "NSimSun", - "宋体", - "SimSun" - ], + "zh": { + "xp": [ + "Microsoft YaHei UI", + "微软雅黑", + "Microsoft YaHei", + "新宋体", + "NSimSun", + "宋体", + "SimSun", + "黑体", + "SimHei" + ], + "normal": [ + "Microsoft YaHei UI", + "微软雅黑", + "Microsoft YaHei", + "黑体", + "SimHei", + "新宋体", + "NSimSun", + "宋体", + "SimSun" + ] + }, "ja": [ "Yu Gothic UI", "游ゴシック",