1

How can I use a specific character of a specific font? And how could I use it in math-mode?

I have tried to use, what I would expect to work:

\documentclass{report}
\usepackage{fontspec}
\newfontfamily\specialfont{mathb12}
\newcommand\myroundtarrow{\specialfont\symbol{"FC}}

\begin{document} \myroundarrow \end{document}

and, amazingly, I DO get the character, but not without a lot of errors on part of Metafont and even one from fontspec saying it can't find the font:

! Package fontspec Error: The font "mathb12/B" cannot be found.

I am aware of the Q/A in here but the solution there produces some of the same errors under TeXLive 2020 xelatex.

Bernard
  • 271,350

1 Answers1

3

You can use \newfontfamily with OpenType or TrueType fonts, not with “legacy” Metafont fonts.

You need to declare the font in the “traditional” way.

\documentclass{article}
\usepackage{fontspec}

\DeclareFontFamily{U}{mathb}{\hyphenchar\font45} \DeclareFontShape{U}{mathb}{m}{n}{ <-5.5> mathb5 <5.5-6.5> mathb6 <6.5-7.5> mathb7 <7.5-8.5> mathb8 <8.5-9.5> mathb9 <9.5-10.5> mathb10 <10.5-> mathb12 }{} \DeclareSymbolFont{mathb}{U}{mathb}{m}{n} \DeclareFontSubstitution{U}{mathb}{m}{n}

% \lefttorightarrow in mathabx \DeclareMathSymbol{\myroundtarrow}{\mathrel}{mathb}{"FC}

\begin{document}

$\myroundtarrow$

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thanks very much, this is clear now, but I have just one question left: How come, if you click on those error messages you DO end up with a representation of the character? – TeX Apprentice Oct 08 '20 at 17:09