环境:Windows+texstudio+texlive
xetex将使用你系统的字体,也就是说你不用自己去编译字体了。
增加字体设定宏包
-
在texlive的命令行下
使用$ fc-list :lang=zh-cn
可以看到你的中文字体。
使用$ fc-list
可以看到你的所有字体。 -
在D:\Edit\texlive2018\texmf-dist\tex\xelatex\zhfontcfg中创建一个“zhfontcfg.sty” 文件如下(没有zhfontcfg文件夹就自己创建):
% xetex/xelatex 字体设定宏包
\ProvidesPackage{zhfontcfg}
\usepackage{fontspec,xunicode}
\defaultfontfeatures{Mapping=tex-text} %如果没有它,会有一些 tex 特殊字符无法正常使用,比如连字符。
% 中文断行
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
%将系统字体名映射为逻辑字体名称,主要是为了维护的方便
\newcommand\fontnamehei{Microsoft YaHei}
\newcommand\fontnamesong{SimSun}
\newcommand\fontnamekai{KaiTi}
\newcommand\fontnamemono{DejaVu Sans Mono}
\newcommand\fontnameroman{Times New Roman}
%设置文档正文字体为宋体
\setmainfont[BoldFont=\fontnamehei]{\fontna