0

I fount the latex template file sometimes define the fonts in sty file like this:

\setCJKmainfont[
BoldFont=AdobeHeitiStd-Regular.otf,
ItalicFont=AdobeKaitiStd-Regular.otf,
SmallCapsFont=AdobeHeitiStd-Regular.otf
]{AdobeSongStd-Light.otf}

sometimes define the main fonts like this:

\setCJKmainfont[
BoldFont=AdobeHeitiStd-Regular,
ItalicFont=AdobeKaitiStd-Regular,
SmallCapsFont=AdobeHeitiStd-Regular
]{AdobeSongStd-Light}

When should we put the font format abbr? Which one is preferred? Is there any more compatible way to define the main font?

2
  • 3
    According to the fontspec manual (Part II, section 2.2 "By file name"), using the first variant you make absolutely clear to fontspec (which is used here under the hood) that what mean a font file name with what you. In the second variant, this is not so clear and the manual suggests, that you add the option Extension = .otf to the list. Jun 22, 2023 at 17:41
  • The truth is the first style could not work(tell me could not fond the font), the second works. I am confusing with this situation, the fisrt style is more clear than the seconds tyle.
    – Dolphin
    Jun 22, 2023 at 17:46

1 Answer 1

4

Choose whichever method is suitable.

font spec

Use Path= for non-installed fonts.

Use Extension=.otf, to save typing if all files are otf.

The asterisk (*) typing shortcut will be replaced by whatever is between the braces ({}).

On Windows, system fonts must be "Install for all users".

MWE

\documentclass{article}
\usepackage{xcolor}
\usepackage{fontspec}

\setmainfont[%
Path=C:/Users/.../.../fonts/x/, %masked
%Extension=.otf,
UprightFont=*,
BoldFont=FreeMonoBold.otf,
ItalicFont=Asavari.ttf,
BoldItalicFont=RobotoCondensed-BoldItalic.otf,
UprightFeatures={Scale=3,Color=brown},
BoldFeatures={Scale=2},
ItalicFeatures={Color=red},
BoldItalicFeatures={Scale=0.8},
]{bkai00m0.TTF}

\begin{document}

蟬

{\itshape italic text}

{\bfseries bold text}

{\bfseries\itshape bold italic text}


\end{document}
1
  • 1
    +1 For the choice of the Chinese character. Jun 23, 2023 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .