# changing font of one (or a small number of) text character only [duplicate]

Possible Duplicate:
Font substitution with XeLaTeX

I am using a text font that unfortunately does not have accents for the letter e, which I need. But I have found a very similar font, and have created a simple \newcommand that I can use to switch font when I need the accent. But naturally, the the old unaccented letter e doesn't match the accented one exactly, so I would like to switch all of the unaccented letter e's in my document to the new font as well, but I would rather not have to use a macro to do this, naturally. [Why don't I just use the new font? Ah, well, the new e looks acceptable with the old font, but the rest of the font is not acceptable.]

Is this possible? What I was hoping for was something like using mathspec "ranges", which allow me to redefine an individual math character's font, but for non-math characters.

I am using lyx, xetex, mathspec, et. al.

[update] well, I should have tried a little harder I guess. I found an answer soon after, by borrowing from an answer I think was built for another purpose, but that works here: Font substitution with XeLaTeX. It's a bit deep in the works, and I never would have figured it out on my own I am sure, but anyway, back to work...sorry to trouble...

\newfontfamily{\JapSubstFont}{newfont}

\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\JapSubst

\XeTeXcharclass"0065=\JapSubst % "0065 is unicode for the letter e

\XeTeXinterchartoks 0 \JapSubst = {\begingroup\JapSubstFont}
\XeTeXinterchartoks 255 \JapSubst = {\begingroup\JapSubstFont}
\XeTeXinterchartoks \JapSubst 0 = {\endgroup}
\XeTeXinterchartoks \JapSubst 255 = {\endgroup}


[upupdate] I know the question is closed, and that I am not sure I should give any more answer, but lest anyone else stumble here and would like to add a small postscript to the effect that the above changes the letter for ALL fonts, and that one has to add statements like

\newfontfamily\fontone{myfontnameone}
\newfontfamily\fonttwo{myfontnametwo}
\providecommand{\enablefontone}{\XeTeXinterchartokenstate=1  \fontone  }
\providecommand{\enablefonttwo}{\XeTeXinterchartokenstate=0  \fonttwo  }


to turn the feature on or off, respectively, for specific fonts.

[up3date] Again, lest someone stumble...I found the latter method didn't quite work as I wanted (e.g. as the substitution also got applied to my sans-serif and typewriter fonts, which now had substitute e's instead of their proper e's). To test for the appropriate font directly is more apt:

\makeatletter % necessary to enable f@...

% will test if current font is the badfont
\newcommand{\iffont}[3]{\ifthenelse{\equal{\f@family}{#1}}{#2}{#3}}

\newfontfamily{\JapSubstFont}{goodfontname}

\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\JapSubst

\XeTeXcharclass"0065=\JapSubst
\XeTeXcharclass"00E9=\JapSubst

% function test for transition into JapSubstFont,
% from either
% class 0 (default, i.e. inside word) tokens
\XeTeXinterchartoks 0 \JapSubst = {\begingroup
}{           %else do nothing
}}
% or class 255 (text or word boundary)
\XeTeXinterchartoks 255 \JapSubst = {\begingroup