From 17bd760a223ad3d9b433907a0cbad9305e7725e3 Mon Sep 17 00:00:00 2001 From: Zeping Lee Date: Sat, 2 Mar 2024 19:33:32 +0800 Subject: [PATCH] Fix Windows font file names --- thuthesis.dtx | 58 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/thuthesis.dtx b/thuthesis.dtx index 5b9f17f2..1caf0d81 100644 --- a/thuthesis.dtx +++ b/thuthesis.dtx @@ -2598,28 +2598,70 @@ % \end{macrocode} % % 使用本地的 Windows 字体文件。 +% +% Windows 的中易楷体和仿宋字体文件名分别为 \file{Simkai.ttf} 和 +% \file{Simfang.ttf}(见 +% \url{https://learn.microsoft.com/en-us/typography/fonts/windows_11_font_list}), +% 而 macOS 版 Word 对应的字体名为 \file{Kaiti.ttf} 和 \file{Fangsong.ttf}。 +% 所以需要进行判断。 % \begin{macrocode} \@namedef{thu@set@cjk@font@windows-local}{% - \setCJKmainfont{SimSun}[% - Path = \thu@windows@font@dir/, - AutoFakeBold = 3, - ItalicFont = KaiTi, - ]% + \IfFileExists{\thu@windows@font@dir/Kaiti.ttf}{ + \setCJKmainfont{SimSun}[% + Path = \thu@windows@font@dir/, + Extension = .ttc, + AutoFakeBold = 3, + ItalicFont = Kaiti, + ItalicFeatures = {Extension = .ttf}, + ]% + \setCJKmonofont{Fangsong}[ + Path = \thu@windows@font@dir/, + Extension = .ttf, + ]% + \setCJKfamilyfont{zhkai}{Kaiti}[ + Path = \thu@windows@font@dir/, + Extension = .ttf, + ]% + \setCJKfamilyfont{zhfs}{Fangsong}[ + Path = \thu@windows@font@dir/, + Extension = .ttf, + ]% + }{ + \setCJKmainfont{SimSun}[% + Path = \thu@windows@font@dir/, + Extension = .ttc, + AutoFakeBold = 3, + ItalicFont = Simkai, + ItalicFeatures = {Extension = .ttf}, + ]% + \setCJKmonofont{Simfang}[ + Path = \thu@windows@font@dir/, + Extension = .ttf, + ]% + \setCJKfamilyfont{zhkai}{Simkai}[ + Path = \thu@windows@font@dir/, + Extension = .ttf, + ]% + \setCJKfamilyfont{zhfs}{Simfang}[ + Path = \thu@windows@font@dir/, + Extension = .ttf, + ]% + } \setCJKsansfont{SimHei}[% Path = \thu@windows@font@dir/, + Extension = .ttf, AutoFakeBold = 3, ]% - \setCJKmonofont{FangSong}[Path=\thu@windows@font@dir/]% \setCJKfamilyfont{zhsong}{SimSun}[% Path = \thu@windows@font@dir/, + Extension = .ttc, AutoFakeBold = 3, ]% \setCJKfamilyfont{zhhei}{SimHei}[% Path = \thu@windows@font@dir/, + Extension = .ttf, AutoFakeBold = 3, ]% - \setCJKfamilyfont{zhkai}{KaiTi}[Path = \thu@windows@font@dir/]% - \setCJKfamilyfont{zhfs}{FangSong}[Path = \thu@windows@font@dir/]% } % \end{macrocode} %