Enhance | Use i18n in font loading
This commit is contained in:
parent
f5ff410951
commit
6f3ff2fddc
@ -119,18 +119,21 @@ def pyglet_load_fonts_folder(folder) -> None:
|
||||
if not font_path.exists():
|
||||
font_path.mkdir(parents=True)
|
||||
return None
|
||||
logger.info(f'loading font folder {font_path}')
|
||||
logger.info(tr().client.load.font.start().format(font_path))
|
||||
start_time = time.time_ns()
|
||||
for dir_path, dir_names, file_names in os.walk(font_path):
|
||||
dir_path = Path(dir_path)
|
||||
for file_name in file_names:
|
||||
file_name = Path(file_name)
|
||||
if file_name.suffix in ('.ttf', '.otf'):
|
||||
logger.debug(f'loading font {dir_path / file_name}')
|
||||
logger.debug(tr().client.load.font.file().format(str(dir_path / file_name)))
|
||||
try:
|
||||
pyglet.font.add_file(str(dir_path / file_name))
|
||||
except Exception:
|
||||
logger.error(traceback.format_exc())
|
||||
logger.error(f'loading font {str(dir_path / file_name)} failed')
|
||||
logger.error(tr().client.load.font.error().format(str(dir_path / file_name), traceback.format_exc()))
|
||||
end_time = time.time_ns()
|
||||
use_time = end_time - start_time
|
||||
logger.info(tr().client.load.font.use_time().format(use_time / 1000000000))
|
||||
|
||||
|
||||
def _call_back(call_back: Callable) -> Callable:
|
||||
@ -255,7 +258,7 @@ class ClientWindow(Window):
|
||||
end_time = time.time_ns()
|
||||
self.use_time = end_time - start_time
|
||||
DR_runtime.client_setup_cause_ns = self.use_time
|
||||
self.logger.info(tr().window.setup.use_time().format(Decimal(self.use_time) / 1000000000))
|
||||
self.logger.info(tr().window.setup.use_time().format(self.use_time / 1000000000))
|
||||
self.logger.debug(tr().window.setup.use_time_ns().format(self.use_time))
|
||||
self.count = 0
|
||||
|
||||
|
@ -47,6 +47,10 @@ setup.use_time = "Client loading has used: {} second"
|
||||
setup.use_time_ns = "Client loading has used: {} nano second"
|
||||
config.save.start = "Saving config……"
|
||||
config.save.done = "Config saved"
|
||||
load.font.start = "Font loading~ from folder {}"
|
||||
load.font.file = "Loading font file: {}"
|
||||
load.font.error = "Font {} Load failed\ntraceback: {}"
|
||||
load.font.use_time = "Font loading has used: {} second"
|
||||
|
||||
[window]
|
||||
setup.start = "Window start loading"
|
||||
|
@ -47,6 +47,10 @@ setup.use_time = "客户端载入花费: {} 秒"
|
||||
setup.use_time_ns = "客户端载入花费: {} 纳秒"
|
||||
config.save.start = "正在保存配置文件"
|
||||
config.save.done = "配置文件保存完成"
|
||||
load.font.start = "正在加载文件夹 {} 下的字体文件"
|
||||
load.font.file = "正在加载字体文件: {}"
|
||||
load.font.error = "字体加载失败: {}\n错误信息: {}"
|
||||
load.font.use_time = "字体加载消耗时间: {} 秒"
|
||||
|
||||
[window]
|
||||
setup.start = "游戏窗口加载开始"
|
||||
|
Loading…
Reference in New Issue
Block a user