[XeTeX] Switching to another font but keeping the context

nico nicolas.marsgui at libertysurf.fr
Sat May 23 16:51:12 CEST 2009


Hi,

I'd like to be able to change on the fly the fonts to use *and* that the  
current family/style/schape used still apply. Calling \setmainfont,  
\setsansfont, etc. would be OK except that it comes back to normal font  
(sffamily, bold or italic vanishes).

An example of the current behaviour:

\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}

{\it{\sffamily

A sans-serif italic text

\setmainfont{URW Palladio L}
\setsansfont{FreeSans}

A normal text in PalladioL...

}}

What I'd like to have is a macro (i call it \switchtofonts) that gives:

\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}

{\it{\sffamily

A sans-serif italic text

\switchtofonts{URW Palladio L}{FreeSans}

The text is still in the sffamily, and italic, using FreeSans!

}}

Is it doable?

Thanks in advance,
BG


More information about the XeTeX mailing list