# Cancellation of Color fontspec font settings while defining microtype context

I found a strange behavior of the microtype package. While using the command \SetExpansion to declare a microtype context with specific parameters, the color settings defined with the fontspec package are no longer available.

Here the code I was using:

\documentclass[12pt,a4paper]{memoir}

\usepackage[italian]{babel}
\usepackage{fontspec}
\usepackage{microtype}

\SetExpansion[
context=MyExpansionContext,
shrink=270,
stretch=270
]{encoding=*}{}

\setmainfont{Linux Libertine}
\setsansfont[Color = FF0000FF]{Linux Biolinum}

\newcommand\Text{Lorem ipsum dolor sit amet, con- sectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.}

\begin{document}

{\sffamily This is a false-latin example:} \Text

\begin{microtypecontext}{expansion=MyExpansionContext}
{\sffamily This is a false-latin example:} \Text
\end{microtypecontext}

\end{document}


which gives as a result:

If I comment out

%\SetExpansion[
%  context=MyExpansionContext,
%  shrink=270,
%  stretch=270
%]{encoding=*}{}


the result is colored as desired, but, obviously, without the specified microtype parameters:

• It works with XeLaTeX. This really isn't the place to report bugs, though. – cfr Nov 16 '16 at 0:59
• @cfr It does not work with XeLaTeX, because XeLaTeX does not support font expansion. Anyhow, where do you suggest to post the topic? – Paolo Polesana Nov 16 '16 at 5:43
• Report it to the package(s) maintainer(s). I'd wait first to see if somebody can tell you which package is buggy or whether both are. But generally bugs should be reported to package maintainers. Usually the documentation will tell you where to report them or who to report them too. (Obviously, this only applies to maintained packages.) – cfr Nov 16 '16 at 16:04
• What I meant, by the way, is that the colour works. Also, it isn't the expansion as such which is the problem. It is the use of the context. It is inserting lua commands directly, it seems. Moreover, the colour cannot be overridden using the ordinary colour commands in either XeTeX or LuaTeX (without an expansion context, obviously). That is, it is not just setting a default colour for sans. It is setting a come-what-may colour for sans. – cfr Nov 16 '16 at 16:08

microtype makes copies of the fonts (to avoid the error ! error: (font expansion): font has been expanded with different stretch limit.) with \(pdf)copyfont, and this looses all font features, not only the color but also e.g. tlig (ligatures) and smcp (small caps):

\documentclass{article}
\usepackage{luatex85}

\begin{document}

\font\testa={Arial:mode=node;script=latn;language=DFLT;+tlig;+smcp;color=FF0000FF;}
{\testa abc --  }  normal

\pdfcopyfont\testb\testa

{\testb abc --  } normal

\end{document}


The problem can also be shown in context:

\starttext

\font\testa={Arial:mode=node;script=latn;language=DFLT;+tlig;+smcp;}
{\testa abc -- }  normal

\copyfont\testb\testa

{\testb abc -- } normal

\stoptext


So I will ask on the context list ...

## Edit

The answer from Hans Hagen is quite clear: \(pdf)copyfont works only on the tfm level and doesn't copy features like tlig, smcp and color. The code of microtype can't work correctly with open type fonts. Report the issue to the microtype maintainer.

• Thank you for the answer. I reported to the maintainer of the microtype package Robert Schlicht (w.m.l@gmx.net) the problem, hoping he will read the email! – Paolo Polesana Nov 17 '16 at 10:19