Fontspec Package With Other Font-Related Packages (charter, etc)

fontsfontspec

I am now switching over to lualatex (hence so many questions), partly in order to be able to use another font, partly to learn lua facilities.

\usepackage{fontspec}  %% should come before microtype
\newfontfamily{\andika}
  [Ligatures=TeX, % recommended
   UprightFont={*},
   ItalicFont={* Italic},
   BoldFont={* Bold},
   BoldItalicFont={* Bold Italic}]{Andika}
\newcommand{\textandikabf}[2][20]{{\andika\bfseries\fontsize{#1}{#1}\selectfont#2}}

Like most people, I have hamstered together style files I have used for years, which include fonts I have used for years, most of which I don't fully understand. I believe fontspec tinkers/overrides some of them. I am trying to figure out what is good practice now.

\usepackage[T1]{fontenc} — presumably, I still leave this.

\usepackage{charter} — was my main font because it is heavier than modern roman, has good math fonts, and is free whereever latex is installed. alas, fontspec seems to override this one, even though I do not use \setmainfont. I am also not sure whether the macos (or other computer system) charter fonts are as good as those included with texlive.

\usepackage[mdbch,ttscaled=true]{mathdesign} — to match the charter on the math font side.

\usepackage{textcomp} — text companion fonts, presumably also still ok. For stuff like the Yen symbol.

\usepackage{microtype} — I believe this has to be loaded after package fontspec.

Ergo, my primary question is how to get back my good latex-native charter font now (and still use andika for highlights). My secondary question is how to deal with these other mentioned font-related packages. Advice [as always] highly appreciated.

PS: (If anyone knows of another good universal and free font on all TeX systems with good math support that would be better for a textbook, feel free to drop me a hint, too. The font catalog lists fonts with mathsupport in https://tug.org/FontCatalogue/mathfonts.html .)

Best Answer

You would not use fontenc together with fontspec. It’s mostly harmless, but it won’t work. The fontspec package switches from 8-bit legacy encodings to Unicode. It is still possible to mix and match if you really want to. You also do not need to load textcomp, with or without fontspec. It’s now part of the LaTeX kernel.

What you actually want to do is load a TrueType or OpenType version of Charter, together with your math font. There are several clones in the TeX Live distribution, including XCharter.

\documentclass{article}
\usepackage[mdbch,ttscaled=true]{mathdesign}
\usepackage{fontspec}

\usepackage[paperwidth=10cm]{geometry} % To format the MWE for TeX.SX
\pagestyle{empty}

\defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }

% There is an XCharter.fontspec file in TeX Live,
% so this command is unnecessary:
%
%\defaultfontfeatures[XCharter]{
%  Ligatures=Common,
%  UprightFont=*-Roman,
%  BoldFont=*-Bold,
%  ItalicFont=*-Italic,
%  SlantedFont=*-Slanted,
%  BoldItalicFont=*-BoldItalic,
%  BoldSlantedFont=*-BoldSlanted,
%  Extension=.otf}

% Andika is available from:
% https://software.sil.org/andika/download/
\defaultfontfeatures[Andika]{
   Ligatures=Common,
   UprightFont={*},
   ItalicFont={* Italic},
   BoldFont={* Bold},
   BoldItalicFont={* Bold Italic}}

\setmainfont{XCharter}
\newfontfamily\andika{Andika}

\newcommand{\textandikabf}[2][20]{{\andika\bfseries\fontsize{#1}{#1}\selectfont#2}}

\begin{document}
An \textit{example} of Charter and \textandikabf[10]{Andika}.

\[ x = ma \]
\end{document}

XCharter/Andika/MathDesign sample

This uses Math Design Charter as the math font and the OTF version of XCharter as the text font. Since both were cloned from the same original font, they match.

There isn’t always an exact match for your text font in a TeX math package, though. When there isn’t, you can use your modern font for letters in math mode. You can set up mathastext, mathspec or unicode-math to do it. If all you need to do is set up the \mathnormal alphabet to use the main text font in italic style, something like this works:

\usepackage{mathdesign} % Or your legacy 8-bit math package
\usepackage{fontspec} % Or any modern font package
\setmainfont{...}
\usepackage[italic]{mathastext}