0

I try to use specific symbols from other (TrueType) fonts (several different fonts) in math mode (as math letters, math operators, ...). So the symbol should be defined via DeclareMathSymbol, I guess. $\mysymbol$ in the TeX file produces the error message "Font shape `U/MyFont/m/n' undefined". I could not repair it via DeclareSymbolFont and DeclareFontShape. (\MyFont{10509} and $\text{\MyFont{10509}}$ does function here, but that's not what I need.) Thanks for help.


%\listfiles
\documentclass{article}
\usepackage{geometry}
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
}
\usepackage{fontspec}
\usepackage{mathtools}

\title{Formula Font Test}
\author{Stefan}
\date{2017-03-15}

\newfontfamily\MyFontFamily[Path=C:/tmp/fonts/]{cambria.ttc}

% \DeclareFontFamily {} {} {}
%\DeclareFontFamily{U}{MyFamilyFont}{m}

\newcommand\MyFont[1]{\MyFontFamily\symbol{#1}}

% \DeclareSymbolFont {} {} {} {} {}
\DeclareSymbolFont{MyFontSymb}{U}{MyFont}{m}{n}

% \DeclareFontShape{U}{MyFontSymb}{m}{n}{  MyFont }{}
%\DeclareFontShape{MyFontSymb}{m}{n}{\UnicodeFontFile{cambria}{\UnicodeFontTeXLigatures}}{}

\DeclareMathSymbol{\othersymbol}{\mathalpha}{letters}{"0B}
\DeclareMathSymbol{\mysymbol}{\mathalpha}{MyFontSymb}{10509}

\usepackage{luacode}
\begin{document}

\maketitle

\MyFont{10509}

$
\othersymbol
\text{ \MyFont{10509} }
\mysymbol
$

\end{document}
2

You can do it like this

\documentclass{article}

\usepackage{fontspec}
\usepackage{mathtools}



\newfontfamily\MyFontFamily{cambria.ttc}[NFSSFamily=cambria]
\newcommand\MyFont[1]{{\MyFontFamily\symbol{#1}}}

\DeclareSymbolFont{MyFontSymb}{TU}{cambria}{m}{n}
\Umathchardef\mysymbol="3 \symMyFontSymb 10509


\begin{document}

\MyFont{10509}
$
x_{\mysymbol} {\mysymbol}
$

\end{document}

enter image description here

But I doubt a bit if it is really needed to set up a new symbol font. A simpler way is in this answer https://tex.stackexchange.com/a/344462/2388

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.