5

I'm using a title font which has very few characters, and I need '+' and '=' for a given title, which are missing. Using fontspec, is it possible to import only these two missing glyphs from another font?

Note: it is a very similar question to this one, but I'd like to know if it can be done easily with fontspec.

  • 1
    Why not use math mode e.g. $1+1=2$? – Leo Liu Aug 12 '11 at 11:10
  • That is a good idea, but my title font is scaled (huge is not big enough for my needs), so the math font doesn't scale the same. – ℝaphink Aug 12 '11 at 11:12
  • 1
    Switch to another font for the two glyphs. – Ulrike Fischer Aug 12 '11 at 14:36
  • @Ulrike: that would work too, but I wanted to know if there was a cleaner way (just in case). – ℝaphink Aug 12 '11 at 14:44
  • The clean way is to use a better font. All other solutions involve a font switch which you can do in various ways (commands, \XeTeXinterclass) but still is a font switch. – Ulrike Fischer Aug 12 '11 at 15:07
3

If the symbols are used only in a few cases, the most efficient solution is to define \newcommand{\biggerplus}{{\myplusfont +}}, where \myplusfont is the declaration for choosing the substitute font.

If you really need to use directly + and =, then I suggest

\newfontfamily{\mytitlefont}{Some Font}
\newcommand{\choosetitlefont}{\mytitlefont\mytitlefonttrue}
\newif\ifmytitlefont
\let\pluschar=+
\catcode`+=\active
\protected\def+{\ifmytitlefont{\myplusfont\pluschar}\else\pluschar\fi}
\let\equalschar==
\catcode`==\active
\protected\def={\ifmytitlefont{\myplusfont\equalschar}\else\equalschar\fi}

Instead of calling \mytitlefont for typesetting the titles, you'll call \choosetitlefont.

Solutions with \XeTeXintercharclass would avoid activating the characters, but will have the conditional anyway.

| improve this answer | |

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.