Font Family

Font Family #

Author: Erhua

Keywords: Font, Font Family, Font Shape, Font Series

Most objects we see in our lives have a property called structure. So what is structure? Basically, we can consider structure as consisting of three parts: shape, material, and size.

The fonts we use for typesetting also have structure, which includes font type (e.g. Song, Li), font shape (e.g. italics, upright, small caps), font series (e.g. medium, bold). These properties are also related to shape and size.

However, because fonts are a series, they can be further divided into more detailed categories. We generally discuss them from the following perspectives:

  • Font Family: Corresponds to a set of fonts that are similar in style and suitable for use together, such as Roman font family, sans-serif font family, etc.
  • Font Shape: Italics, upright, small caps, etc.
  • Font Series: Medium, bold, etc.

LaTeX has three default font families: Roman font family, sans-serif font family, typewriter font family.

There are two commands that can be used to locally use these font families:

Font Family With Argument Command Declaration Command
Roman \textrm{ } \rmfamily
Sans-serif \textsf{ } \sffamily
Typewriter \texttt{ } \ttfamily

However, for Chinese, there are not many variants, so we generally use font families to distinguish (e.g. Song, Li).

Therefore, the choice of Chinese fonts is separate from Western fonts, which should be noted.

The CTeX package and its document classes (such as ctexart) have defined some combined fonts separately, which allow Chinese to use bold (\bfseries) and italics (\itshape) functions just like Western fonts, and redefine \rmfamily to apply to Chinese as well. This defaults the font combination for Chinese to rm, with regular font being Song, bold font being Hei, and italics font being Kai, which conforms to our usual usage.

I am a person (Song), \textbf{what about you (Hei)?} \textit{No, it's Wang (Kai)!}

The font family for Chinese has been partially predefined in the CTeX package and its document classes. Four font families have been configured for Windows, and the following simplified commands are provided for use.

{\songti I am Songti},{\heiti I am Heiti},{\fangsong I am Fangsong},{\kaishu I am Kaishu}.

Basic Font Settings #

However, the above settings are still too outdated, so now we use XeLaTeX. Use the fontspec package to call fonts.

For English: Set the main Roman font family, sans-serif font family, and typewriter font family for the body.

\setmainfont[Optional options]{Font Name}
\setsansfont[Optional options]{Font Name}
\setmonofont[Optional options]{Font Name}
After setting, fontspec will automatically find and match the corresponding bold font, italics, etc., so that we can use \bfseries and \itshape effectively. If not, the following settings are needed.
       BoldFont       = texgyrepagella-bold.otf ,
       ItalicFont     = texgyrepagella-italic.otf ,
       BoldItalicFont = texgyrepagella-bolditalic.otf ]{texgyrepagella-regular.otf}

For Chinese:

\setCJKmainfont[Optional options]{Font Name}
\setCJKsansfont[Optional options]{Font Name}
\setCJKmonofont[Optional options]{Font Name}
\setCJKfamilyfont{Chinese Font Family}{Font Name}
\setCJKmainfont[BoldFont = STLibian-SC-Regular,]{TpldKhangXiDictTrial}

Changing Fonts Locally in the Body #

How to change fonts locally in the content of an article

For English:

A few words, a few sentences: simply define a new command

% Redefine a new font family command:
\newfontfamily<Command>[Optional parameters]{Font Name}
% Example:
hello, {\ptmr everyone}. this is my blog---{\fugu yeyuqiudeng}

For Chinese:

% Redefine a new font family command:
\newCJKfontfamily<Command>[Optional parameters]{Font Name}
% Example:

Examples of Common Fonts #