As Andrey points out, the key is the concept of "interchar tokens". Suppose you have some CJK characters that doesn't appear in the normal font and you want to use another for them; say that the characters are U+4E01 and U+4E02.
Then the following will do:
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{<a font>}
\newfontfamily{\JapSubstFont}{<another font with the missing chars>}
\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\JapSubst
\XeTeXcharclass"4E01=\JapSubst
\XeTeXcharclass"4E02=\JapSubst
\XeTeXinterchartoks 0 \JapSubst = {\begingroup\JapSubstFont}
\XeTeXinterchartoks 255 \JapSubst = {\begingroup\JapSubstFont}
\XeTeXinterchartoks \JapSubst 0 = {\endgroup}
\XeTeXinterchartoks \JapSubst 255 = {\endgroup}
Each time that a character in the \JapSubst
charclass will be at the start or end of a "word" or be preceded or followed by a "normal" character, it will be typeset in the \JapSubstFont
.
One can also specify a range:
\count255="4E01
\loop\ifnum\count255<"5000
\XeTeXcharclass\count255=\JapSubst
\advance\count255 by 1
\repeat
Using unicode-math
:
\usepackage{amsmath} % always load before mathspec or unicode-math
\usepackage[math-style=ISO]{unicode-math} % try sans-style=upright
\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}
\setmainfont[Numbers={OldStyle,Proportional},SmallCapsFeatures={LetterSpace=6},%
BoldFont={Myriad Pro Bold},BoldFeatures={LetterSpace=3}]{Minion Pro}
\setsansfont[Numbers={OldStyle,Proportional},LetterSpace=3]{Myriad Pro}
\setmonofont{Crystal}
\setmathfont{xits-math.otf}
\setmathfont[range=\mathup/{num,latin,Latin,greek,Greek}]{Minion Pro}
\setmathfont[range=\mathsf/{num,latin,Latin,greek,Greek}]{Myriad Pro}
\setmathfont[range=\mathbfsf/{num,latin,Latin,greek,Greek}]{Myriad Pro Bold}
\setmathfont[range=\mathit/{num,latin,Latin,greek,Greek}]%
{Minion Pro Italic}
\setmathfont[range=\mathsfit/{num,latin,Latin,greek,Greek}]%
{Myriad Pro Italic}
\setmathfont[range=\mathbfsfit/{num,latin,Latin,greek,Greek}]%
{Myriad Pro Bold Italic}
\setmathfont[range=\mathtt->\mathup]{Crystal}
\let\mathbf\mathbfsf
\let\mathbfit\mathbfsfit
\AtBeginDocument{\let\phi\varphi}
(N.B. unicode-math
loads fontspec
, xltxtra
, and xunicode
)
mathbb
, mathscr
, &c. all have sensible defaults with this. If you want, say, serifed mathbb
, you could add \setmathfont[range=\mathbb/{Latin}->\mathup,Scale=MatchUppercase]{Hoefler Text Engraved}
. The /{Latin}
part applies it only to uppercase latin letters.
- Use
BoldFont
and BoldFeatures
with fontspec
. For unicode-math
, I just used \let
commands, although I know there's probably a more elegant way to do this.
- Removing
MnSymbol
frees up a lot of math alphabets, and unicode-math
increases the limit.
- Apparently Ubuntu Mono is bugged; I couldn't use it, so I tested with Crystal. And it works.
EDIT: To use Minion for even more symbols, you could replace the \mathup
line with:
\setmathfont[range={\mathup/{num,latin,Latin,greek,Greek},\question,\exclam,\mathdollar,%
\percent,\ampersand,\lparen,\rparen,\plus,\comma,\period,\mathslash,\mathcolon,%
\semicolon,\less,\equal,\greater,\backslash,\rbrack,\lbrack,\atsign,\vert,\lbrace,%
\rbrace,\times,\div}]{Minion Pro}
Best Answer
Just use the scaling feature of
fontspec
(inherited byunicode-math
):On the other hand, mixing Asana Math for math and the Roboto font doesn't seem a good choice; a math intensive document shouldn't be typeset in a sans serif font for which there's no real matching math font available.