Skip to content

Instantly share code, notes, and snippets.

@iydon
Created October 18, 2021 14:03
Show Gist options
  • Save iydon/6991ceee15856e8a287aa57358740962 to your computer and use it in GitHub Desktop.
Save iydon/6991ceee15856e8a287aa57358740962 to your computer and use it in GitHub Desktop.
配置 sharelatex.cra.moe 字体(不知道具体字体名称,所以抑制了 `no-script "CJK"` 警告)
% https://sikouhjw.gitee.io/2021/02/14/2021-02-14-fontset-overleaf/
% https://www.overleaf.com/latex/templates/using-the-ctex-package-on-overleaf-zai-overleafping-tai-shang-shi-yong-ctex/gndvpvsmjcqx
% https://zhuanlan.zhihu.com/p/145429470
\GetIdInfo$Id: ctex.dtx 81d4c90 2020-10-19 20:24:58 +0800 Qing Lee <sobenlee@gmail.com> $
{SUSTech fonts definition (CTEX)}
\ProvidesExplFile{ctex-fontset-sustech.def}
{\ExplFileDate}{2.5.5}{\ExplFileDescription}
\RequirePackage{xpatch}
\xpatchcmd \fontspec_new_script:nn
{ \__fontspec_warning:nxx }
{ \__fontspec_info:nxx }
{}{\fail}
\newfontscript{CJK}{hani}
\ctex_fontset_case:nnnn
{ \ctex_fontset_error:n { ubuntu } }
{
\ctex_zhmap_case:nnn
{
\setCJKmainfont { :2:NotoSerifCJK-Regular.ttc }
[ BoldFont = :2:NotoSerifCJK-Bold.ttc, ItalicFont = gkai00mp.ttf ]
\setCJKsansfont { :2:NotoSansCJK-Regular.ttc }
[ BoldFont = :2:NotoSansCJK-Bold.ttc ]
\setCJKmonofont { :2:NotoSerifCJK-Regular.ttc }
[ BoldFont = :2:NotoSerifCJK-Bold.ttc ]
\setCJKfamilyfont { zhsong } { :2:NotoSerifCJK-Regular.ttc }
[ BoldFont = :2:NotoSerifCJK-Bold.ttc ]
\setCJKfamilyfont { zhhei } { :2:NotoSansCJK-Regular.ttc }
[ BoldFont = :2:NotoSansCJK-Bold.ttc ]
\setCJKfamilyfont { zhkai } { gkai00mp.ttf }
\ctex_punct_set:n { ubuntu }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
\ctex_punct_map_family:nn { \CJKttdefault } { zhsong }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib }
\ctex_punct_map_bfseries:nn
{ \CJKrmdefault, \CJKttdefault, zhsong }
{ zhsongb }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhsong } { ubuntu }
\ctex_punct_set:n { ubuntu }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { ubuntu } }
}
{
\ctex_set_upmap_unicode:nnn { upserif }
{ :2:NotoSerifCJK-Regular.ttc } { :2:NotoSerifCJK-Bold.ttc }
\ctex_set_upmap_unicode:nnn { upsans }
{ :2:NotoSansCJK-Regular.ttc } { :2:NotoSansCJK-Bold.ttc }
\ctex_set_upmap_unicode:nnn { upmono }
{ :2:NotoSansMonoCJK-Regular.ttc } { :2:NotoSansMonoCJK-Bold.ttc }
\ctex_set_upmap:nnn { upserifit } { gkai00mp.ttf } { }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
\ctex_set_upfamily:nnn { zhfs } { upzhmono } { }
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } { }
}
{
\setCJKmainfont { FandolSong-Regular }
[
Extension = .otf,
BoldFont = FandolSong-Bold,
ItalicFont = FandolKai-Regular
]
\setCJKsansfont { FandolHei-Regular }
\setCJKmonofont { FandolFang-Regular }
\setCJKfamilyfont { zhsong } { FandolSong-Regular.otf }
\setCJKfamilyfont { zhhei } { FandolHei-Regular.otf }
\setCJKfamilyfont { zhkai } { FandolKai-Regular.otf }
\setCJKfamilyfont { zhfang } { FandolFang-Regular.otf }
}
\NewDocumentCommand \songti { } { \CJKfamily { zhsong } }
\NewDocumentCommand \heiti { } { \CJKfamily { zhhei } }
\NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } }
\NewDocumentCommand \fangsong { } { \CJKfamily { zhfang } }
%%
%%
%% End of file `ctex-fontset-sustech.def'.
\documentclass[fontset=sustech]{ctexart}
\usepackage{zhlipsum}
\begin{document}
\zhlipsum
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment