I've found some inspiration in the XeTeX reference guide (Character Classes, pages 14 and 15) and in these Q+A, Font substitution with XeLaTeX and Replacing "a" in latin modern. This is my try. I've installed http://www.ctan.org/tex-archive/fonts/heuristica by unzipping+copying files into my TeX distribution's local directory followed by mktexlsr
and I am using the OTF file directly. I am using scaling of 0.86
, 0.92
didn't look right.
By the way, I like the approach with \xeCJKDeclareSubCJKBlock
from xeCJK
package, but it's adding some extra spaces before and after digit 1
, so please find it among the commented lines. There is an extended example of using this method, Combining Chinese, Japanese and Korean text with xeCJK.
% run: xelatex mal-one.tex
\documentclass[letterpaper,12pt]{article}%amsart
\pagestyle{empty}
% There are some extra spaces before and after "1", but it works...
%\usepackage{xeCJK}
%\xeCJKDeclareSubCJKBlock{one}{"0031}
%\setmainfont[Scale=0.92,RawFeature=+onum]{Heuristica-Regular.otf}
%\setCJKmainfont[one,Scale=0.86,RawFeature=-onum]{Heuristica-Regular.otf}
%\ifx
\usepackage{fontspec}
\setmainfont[RawFeature=+onum,Scale=0.92]{Heuristica-Regular.otf}
\newfontfamily{\mfont}[RawFeature=-onum,Scale=0.86]{Heuristica-Regular.otf}
\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\msub
\XeTeXcharclass"0031=\msub
\XeTeXinterchartoks 0 \msub = {\begingroup\mfont}
\XeTeXinterchartoks 255 \msub = {\begingroup\mfont}
\XeTeXinterchartoks \msub 0 = {\endgroup}
\XeTeXinterchartoks \msub 255 = {\endgroup}
%\fi
\begin{document}
012782
\end{document}

Next option would be to use mapping file (teckit_compile
). I enclose the mapping file (mal-one-bonus.map
) which is first processed by:
teckit_compile -o mal-one-bonus.tec mal-one-bonus.map
Instead of activating +onum
we defined own character mapping. The source code is:
; This is mal-one-bonus.map file...
LHSName "input"
RHSName "output"
pass(Unicode)
UniClass [inputs] = (U+0030 U+0032..U+0039)
UniClass [outputs] = (U+F643 U+F645..U+F64C)
[inputs] <> [outputs]
Then we run xelatex mal-one-a.tex
(it doesn't work with lualatex
):
% run: xelatex mal-one-a.tex
\documentclass[letterpaper,12pt]{article}%amsart
\pagestyle{empty}
\usepackage{fontspec}
\setmainfont[Scale=0.92,Mapping=mal-one-bonus]{Heuristica-Regular.otf}
% RawFeature=+onum,
\begin{document}
012782
\end{document}
I am thinking if a ligature (FeatureFile
) could be used to solve this problem in lualatex
. This is it, a new feature file (mal-feature.fea
):
languagesystem DFLT dflt;
languagesystem latn dflt;
# A new ligature...
feature liga {
sub one.taboldstyle by one;
} liga;
We active it by lualatex mal-one-b.tex
(it doesn't work with xelatex
):
% run: lualatex mal-one-b.tex
\documentclass[letterpaper,12pt]{article}%amsart
\pagestyle{empty}
\usepackage{fontspec}
\usepackage{luatextra}
\setmainfont[Scale=0.92,FeatureFile=mal-feature.fea,RawFeature=+liga;+onum]{Heuristica-Regular.otf}
\begin{document}
012782
\end{document}
ebgaramond
font for another example. – Bernard May 19 '14 at 23:48