HFUTTUG / HFUT_Thesis

LaTeX Thesis Template for Hefei University of Technology
LaTeX Project Public License v1.3c
150 stars 24 forks source link

Bump to latest fontset setting for different OSs #16

Closed l1teng closed 2 years ago

l1teng commented 2 years ago

Related Materials

ci test on macos-latest failed with the following log,

/usr/local/texlive/2022/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-macnew.d
[72](https://github.com/HFUTTUG/HFUT_Thesis/runs/5966403167?check_suite_focus=true#step:4:72)
ef:99: Package fontspec Error: The font "Kaiti SC" cannot be found.

The same issue can also be checked from here. One contributor from the CTex team suggested that using macnew fontset instead of mac fontset(ref: link).

Suggestion

https://github.com/HFUTTUG/HFUT_Thesis/blob/f3319fa92604348b15d928902b7eca3e59a2806e/hfutthesis.cls#L674-L689

However, I do not have that much confidence about this revision. Hence, raise this issue for discussion.

LaureatePoet commented 2 years ago

求助 @zepinglee 大佬。

此外我们看到 Liam大佬的博客 :CTeX 2.4.14:macOS 字体配置升级,感觉改为fontset=macnew 问题不大。

但比较疑虑 会不会对模板预设字体造成影响 image

sikouhjw commented 2 years ago

这里改不改 macnew 都不是关键,ctex 宏集会自动检测。

sikouhjw commented 2 years ago

找不到字体估计是 mac 的问题。

但比较疑虑 会不会对模板预设字体造成影响

%<*macold>
    \setCJKmainfont { STSong     }
      [ BoldFont = STHeiti, ItalicFont = STKaiti ]
    \setCJKsansfont { STXihei    } [ BoldFont = STHeiti ]
    \setCJKmonofont { STFangsong }
    \setCJKfamilyfont { zhsong } { STSong     }
    \setCJKfamilyfont { zhhei  } { STHeiti    }
    \setCJKfamilyfont { zhfs   } { STFangsong }
    \setCJKfamilyfont { zhkai  } { STKaiti    }
%</macold>
%<*macnew>
    \setCJKmainfont { Songti~SC~Light }
      [
        BoldFont       = Songti~SC~Bold,
        ItalicFont     = Kaiti~SC,
        BoldItalicFont = Kaiti~SC~Bold
      ]
    \setCJKsansfont { PingFang~SC }
    \setCJKmonofont { STFangsong  }
    \setCJKfamilyfont { zhsong } { Songti~SC~Light } [ BoldFont = Songti~SC~Bold ]
    \setCJKfamilyfont { zhhei  } { Heiti~SC~Light  } [ BoldFont = Heiti~SC~Medium ]
    \setCJKfamilyfont { zhpf   } { PingFang~SC     }
    \setCJKfamilyfont { zhfs   } { STFangsong      }
    \setCJKfamilyfont { zhkai  } { Kaiti~SC        } [ BoldFont = Kaiti~SC~Bold ]
    \setCJKfamilyfont { zhli   } { Baoli~SC        }
    \setCJKfamilyfont { zhyou  } { Yuanti~SC~Light } [ BoldFont = Yuanti~SC~Regular ]
%</macnew>

^1可以看出,old 和 new 相对于你现在模板里的设置是有影响的,所以这里建议手动设置一下字体

\cs_new_protected:Npn \__gdut_load_cjk_font_mac:
  {
    \__gdut_setCJKmainfont:nn   { STSongti-SC }
      {
        UprightFont    = *-Light,
        BoldFont       = *-Bold,
        ItalicFont     = *-Light,
        BoldItalicFont = *-Bold
      }
    \__gdut_setCJKsansfont:nn   { STHeitiSC   }
      {
        UprightFont    = *-Medium,
        AutoFakeBold   = true,
        ItalicFont     = *-Medium,
        BoldItalicFont = *-Medium
      }
    \__gdut_setCJKmonofont:n    { STFangsong  }
    \__gdut_set_cjk_font_kai:nn { STKaitiSC   }
      {
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Bold
      }
  }

^2

zepinglee commented 2 years ago

这个问题应该是因为 github action 的 macOS 系统中没有 Kaiti SC 导致的。

设置 fontset = macnew 不能解决问题。用户设置的 fontset 是在模板中处理的,并没有 macnew 的选项,也没有传递给 ctex。这是因为有段时间 ctex-kit 更新不及时,导致在当时最新的 macOS 10.15 无法配置正确的字体,同时也是为了在 Overleaf 平台自动调用 Noto CJK 字体(见 https://github.com/tuna/thuthesis/pull/498)。实际上传给 ctex 的总是 fontset = nonehttps://github.com/HFUTTUG/HFUT_Thesis/blob/f3319fa92604348b15d928902b7eca3e59a2806e/hfutthesis.cls#L405

个人建议没必要配置 macOS 的 CI。模板在不同平台编译只有字体的差异,而 github action 的 Windows 和 macOS 又没有对应的中文字体,所以 CI 的意义不大。

l1teng commented 2 years ago

Thanks for the valuable advice, we decide deprecate ci testing on macOS.

Close this issue.