## LaTeX forum ⇒ XeTeX ⇒ Selecting a different font for numbers in main font

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
tafi
Posts: 42
Joined: Sat May 07, 2011 12:01 am

### Selecting a different font for numbers in main font

I'm writing a thesis using XeLaTeX, and have so far specified my fonts using the mathspec package.

I like the look of Adobe's Arno Pro and am using that as the main font. For maths I've been using Mastic (which is like STIX but with a couple of usefull modifications). Some might think it's a weird combo but I think it works.

My main problem is to do with numbers. Using different sets of numbers for maths and text looks very bad. I would really prefer to use the Mastic or STIX or XITS numbers throughout the document, but I can't find a command to change the numbers range of the mainfont.

What I need is a command like:

`\setmainfont(Digits){Mastic}`

But of course no such command exists. Does anyone know of an alternative way to change the mainfont numbers?
Last edited by cgnieder on Mon Oct 22, 2012 11:56 am, edited 1 time in total.

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am
did you read the mathspec documentation?

tafi
Posts: 42
Joined: Sat May 07, 2011 12:01 am
Um, yes I have, several times. Have you?

If you did you'd probably already know that mathspec does not provide the command for setting the main text font, it is fontspec which does this.

Mathspec provides commands to allow the setting of digits, latin and greek in maths fonts. I currently have the following commands to set my maths font(s)

`\setmathfont(Digits){Font1}\setmathfont(Latin){Font2}\stemathfont(Greek){Font3}`

However, when you set the main font there is no (Digits) option provided by fontspec so the commands

`\setmainfont(Latin){TextFont}\setmainfont(Digits){Font1}`

are not possible (at least not for me). Unless I am missing something which is not obvious from the documentation.

That is why I have posed the question, and I will gratefully accept constructive comments on whether or not a solution exists.
Last edited by Stefan Kottwitz on Thu Jun 07, 2012 8:46 am, edited 1 time in total.
Reason: code marked

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am
ok, a misunderstanding. I thought you want it the other way round: using in math the text digits

tafi
Posts: 42
Joined: Sat May 07, 2011 12:01 am
I see,

Yes the best solution I have so far is to share the digits from the mainfont (Arno) with the maths latin and greek of Mastic with the following commands:

`\setmainfont[Mapping=tex-text]{Arno Pro}\setmathsfont(Digits)[Numbers={Lining,Proportional}]{Arno Pro}\setmathsfont(Latin)[Scale=MatchLowercase]{Mastic}\setmathsfont(Greek)[Scale=MatchLowercase]{Mastic}`

However, the Arno Pro digits really don't look quite like professional mathematics, so I really would prefer it to be the other way around (to keep Matic's digits and then use them in the mainfont)

tafi
Posts: 42
Joined: Sat May 07, 2011 12:01 am
The best workaround I have found so far is to use "character tokens" as described in a tex.stackexchange thread:

http://tex.stackexchange.com/questions/10248/font-selection-in-xetex-for-specific-characters

Thus the font definition part of my preamble now looks like this:

`\setmainfont[Mapping=tex-text]{Arno Pro} \XeTeXinterchartokenstate=1\chardef\CharNormal=0\chardef\CharBound=255\newXeTeXintercharclass\CharNumbers\XeTeXcharclass`0=\CharNumbers\XeTeXcharclass`1=\CharNumbers\XeTeXcharclass`2=\CharNumbers\XeTeXcharclass`3=\CharNumbers\XeTeXcharclass`4=\CharNumbers\XeTeXcharclass`5=\CharNumbers\XeTeXcharclass`6=\CharNumbers\XeTeXcharclass`7=\CharNumbers\XeTeXcharclass`8=\CharNumbers\XeTeXcharclass`9=\CharNumbers\newtoks\TokSetfont\TokSetfont={\begingroup\fontspec{Mastic}}\XeTeXinterchartoks\CharNormal\CharNumbers=\TokSetfont\XeTeXinterchartoks\CharBound\CharNumbers=\TokSetfont\XeTeXinterchartoks\CharNumbers\CharNormal={\endgroup}\XeTeXinterchartoks\CharNumbers\CharBound={\endgroup} \setmathsfont(Digits)[Numbers={Lining,Proportional}]{Mastic}\setmathsfont(Latin)[Scale=MatchLowercase]{Mastic}\setmathsfont(Greek)[Scale=MatchLowercase]{Mastic}`

I don't understand the inner workings of this solution, so I have no idea if this can be simplified. However, it does give the desired result. It certainly is a drain on resources in compilation (tens of times slower than without it).

I would love to know if there are any easier (and more resource efficient) ways of achieving the same thing using a package or some package options.