9

See this comment; I am involved in a project that needs to have (automatic) XeLaTeX compilation of various language files on both Mac and Linux (usually Fedora or Debian or Ubuntu), and apparently the default fonts are not at all the same. Is there anything I can do to ensure this kind of portability without asking the user to install new fonts?

Currently apparently this works on Fedora:

\usepackage[noindent,UTF8]{ctexcap}
\setCJKmainfont{AR PL UMing CN}
\setCJKsansfont{WenQuanYi Zen Hei}
\setCJKmonofont{WenQuanYi Zen Hei Mono}

but I needed to change to e.g.

\setCJKmainfont[BoldFont=STHeiti,ItalicFont=STKaiti]{STSong}
\setCJKsansfont[BoldFont=STHeiti]{STXihei}
\setCJKmonofont{STFangsong}

(from this answer) though I know that Mac has lots of other Chinese fonts available too.

Ideally, there would be a solution with some sort of fallback option, but I don't know anything about xecjk (or cjk, for that matter) and in any case that option (as here) seems to be more related to when characters are not present in a font, not when a font isn't present.

Thanks!

  • Does it matter whether the documents produced look the same? – cfr Dec 5 '14 at 16:08
  • No (well, within reason). What matters is having one codebase that can be run on various systems. I mean, we don't want a totally crappy font, but otherwise that is much secondary - it's documentation which otherwise doesn't have that much presentation value in any case. – kcrisman Dec 5 '14 at 16:16
  • For posterity, Wikipedia’s List of CJK fonts contains various freely available ones. – svenper Dec 23 '18 at 9:23
11

Portable, and consistent solution

Fandol fonts are reliable portable fonts for typesetting Simplified Chinese in TeX.

Fandol fonts are not perfect: compared to the other commercial fonts, the character set of Fandol fonts is somewhat restricted, and the puncuations need to be tuned.

Luckily, Fandol is a complete series of Chinese fonts in OpenType format, and well designed for typesetting.

enter image description here

% !TEX program = XeLaTeX
% !TEX encoding = UTF-8
\documentclass[UTF8,nofonts]{ctexart}
\setCJKmainfont[BoldFont=FandolSong-Bold.otf,ItalicFont=FandolKai-Regular.otf]{FandolSong-Regular.otf}
\setCJKsansfont[BoldFont=FandolHei-Bold.otf]{FandolHei-Regular.otf}
\setCJKmonofont{FandolFang-Regular.otf}

\begin{document}

\begin{tabular}{|l|l|l|l|}
\hline
 & \multicolumn{3}{c|}{Series/Shape} \\ \cline{2-4}
Family & \verb=\mdseries= & \verb=\bfseries= & \verb=\mdseries\itshape= \\ \hline
\verb=\rmfamily= & 宋体 & \textbf{粗宋体} & \textit{楷体} \\
\verb=\sffamily= & \textsf{黑体} & \textsf{\textbf{粗黑体}} & \\
\verb=\ttfamily= & \texttt{仿宋体} &&\\ \hline
\end{tabular}

\end{document}

The problem is, most Chinese fonts are expensive commercial ones, you simply have little choice for free Chinese fonts. And what's more, Fandol font bundle is the only choice preinstalled in TeX Live (or MacTeX, MiKTeX) if you use XeTeX or LuaTeX. Therefore, it is now the only portable way to typesetting Simplified Chinese documents in TeX.

Yes there are also Arphic fonts, but only subfonts for CJK package in Type1 format are provided in TeX distributions. Only two families (gbsn and gkai) for Simplified Chinese, or two corresponding families (bsmi and bkai) for Traditional Chinese are provided by Arphic.

Some sort of fallback option for rare glyphs?

No. We don't have enough fonts available for that.

Now we have some good free fonts for large character sets. For example the Souce Han Sans fonts. But they are pre-installed neither in TeX distributions, nor in operation systems.

Something native?

Yes it is possible. In the developer version (ver 2.x) of ctex package, we defined several different font sets, and the package will detect the operation system and select a native font set if you wish.

  • SinoType fonts are automatically selected for Mac.
  • ZhongYi fonts are automatically selected for Windows.
  • Fandol fonts are automatically selcted otherwise. (No, we don't use the incomplete Arphic fonts as default fonts, let alone WenQuanYi.)

And we do provide options to select Arphic and WenQuanYi fonts (fontset=ubuntu option), there are also options for Adobe fonts and Founder fonts.

  • Interesting. But what versions of TeX Live is it in? The font "FandolSong-Regular" cannot be found. Ideally we would have a solution that did not require a user to upgrade their TeX distro just to build the documentation. – kcrisman Dec 5 '14 at 16:58
  • @kcrisman: TeX Live 2014 is fine. You should use the TeX Live from TUG, not the texlive-*** packages for Debian or Ubuntu, which are incomplete TeX live. The files are located at texlive/2014/texmf-dist/fonts/opentype/public/fandol. If you do have the fonts but you just cannot compile: one possible problem is how fontspec (I mean XeTeX) find your font file. You should use the file name (with .otf) of the fonts to force XeTeX to find the fonts via kpathsea library. – Leo Liu Dec 5 '14 at 17:11
  • @kcrisman: For Linux, you should also follow the instructions in section 3.4.4 of TeX Live 2014 document: 3.4.4 System font configuration for XeTeX and LuaTeX. This helps the fontconfig library to find the fonts. – Leo Liu Dec 5 '14 at 17:15
  • 1
    @kcrisman: I'm afraid that Fandol fonts were released after TeX Live 2013 released. The initital version, w.r.t README, is on 2013/07/31. – Leo Liu Dec 5 '14 at 17:24
  • 1
    @kcrisman: It's fine. Configure your editor/IDE/library/script to ignore the warnings. It is common that not all NFSS shapes are defined for Chinese, since there is no concept of italic or slanted in Chinese typesetting. And it is common that not all OpenType features (e.g. 'CJK' script) are supported for a specific font. – Leo Liu Dec 6 '14 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.