# Chartwell fonts and changing colour with ligatures

Bit of a niche question. There is a beautiful set of TrueType fonts called Chartwell designed for producing graphs from text. I am trying to get these to work in Latex. I have switched to Xe(La)tex, and can now get the fonts to appear. However I would like to change text colour without sequence of numbers being split into two. Best explained with some code and a picture.

\documentclass[13pt]{article}
\usepackage{fontspec}
\usepackage{xcolor}

% Now define your quick commands for switching fonts
\setmainfont{ChartwellRose}
\newfontfamily\cwrose[Ligatures=Rare, Color=blue]{ChartwellRose}

\begin{document}
\raggedright

Here is the text without ligatures

\fontsize{48}{60}
\selectfont
40+20+50
\rmfamily
\normalsize

Here is the text with ligatures

\cwrose
\fontsize{48}{60}
\selectfont
40+70
\rmfamily
\normalsize

Here is the text with a colour change inserted

\cwrose
\fontsize{48}{60}
\selectfont
\rmfamily
\normalsize

And as you can see the colour change has broken the effect of enabling the ligatures and the 'rose' is now presented as two separate objects (rather than a single object with 2 different colours.

\end{document}


Is it possible therefore to change the colour of a part of the text without the ligature formation being broken?

Here is a screenshot of the compiled example and here is a screenshot of unbroken form of the last example

-
Not in XeTeX, color will always break text flow and hence the ligatures, and \addfontfeature just defines a new font from the current one plus the requested features. Possible with LuaTeX though, if you are interested in LuaTeX solutions. – Khaled Hosny Feb 18 '13 at 22:21
Thanks for the advice. At least I know to stop looking. I'll leave the question open just a little longer in case someone else has an alternative suggestion. – drstevok Feb 19 '13 at 8:17
So I have just discovered the sparklines package. Should have worked out that many of the things that Chartwell does can already be done in latex. Will use these instead of chartwell! – drstevok Feb 20 '13 at 15:49

I can confirm that FF Chartwell works as intended using the luacolor package.

Edit: As requested by Stephan here is a MWE. This is for luatex only (so this is a workaround rather than a complete answer to the question by drstevok).

\documentclass{article}

%Fontspec
\usepackage{fontspec}

%CHARTWELL (Be sure to load style set 1, otherwise the ligatures won't be activated.)
\newfontface\cwp[StylisticSet={1}]{ChartwellPies}
\newfontface\cwr[StylisticSet={1}]{ChartwellRose}
\newfontface\cwb[StylisticSet={1}]{ChartwellBars}
\newfontface\cwbv[StylisticSet={1}]{ChartwellBarsVertical}
%etc.

%COLORS (Works exactly the same as the regular latex color package.}
\usepackage{luacolor}
\definecolor{aut1}{RGB}{255,51,0}
\definecolor{aut2}{RGB}{255,102,0}
\definecolor{aut3}{RGB}{255,153,0}
\definecolor{aut4}{RGB}{255,204,0}
\definecolor{white}{RGB}{255,255,255}

\begin{document}

\begin{figure}
\centering
\fontsize{100}{120}
\cwp \textcolor{aut1}{24}+\textcolor{aut2}{31}+\textcolor{aut3}{40}+\textcolor{aut4}{5}+\textcolor{white}{A}\\
\end{figure}

\begin{figure}
\centering
\fontsize{100}{120}
\cwr\textcolor{aut1}{14}+\textcolor{aut2}{30}+\textcolor{aut3}{12}+\textcolor{aut4}{44}+\textcolor{white}{A}\\
\end{figure}

\begin{figure}
\centering
\fontsize{100}{120}
\cwb \textcolor{red}{50}+\textcolor{blue}{31}+\textcolor{green}{19}\textcolor{aut4}{=}\\
\end{figure}

\begin{figure}
\centering
\fontsize{100}{120}
\cwbv \textcolor{red}{50}+\textcolor{blue}{31}+\textcolor{green}{19}\\
\end{figure}

\end{document}


-
Could you elaborate a little? I assume this will requite LUATeX? Could you reconstruct the MWE from the question so that it will work with LuaTeX? – Stephan Lehmke Dec 17 '13 at 8:33

This can’t be done in XeTeX, color will always break text flow and hence the ligatures, and \addfontfeature just defines a new font from the current one plus the requested features, and inter-font ligatures will not work of course. It might be possible with LuaTeX though when using the luacolor package.

-
How about with \font\foo="Some Font:color=DDFFAA"? – morbusg Aug 12 '13 at 8:38
@morbusg: Not sure how that is can help with the situation described here? – Khaled Hosny Aug 12 '13 at 8:54
I'm not sure either, I was just thinking of something like: \def\f{Courier:color}\font\r="\f=DD0000"\font\g="\f=00DD00"\font\b="\f=0000DD"\‌​r15+\g32+\b18\bye, But I realized that the font-change is probably going to kill the ligas as well. – morbusg Aug 12 '13 at 11:54
Right, there can’t be any inter-font ligatures (and \addfontfeature basically does that, anyway). – Khaled Hosny Aug 12 '13 at 12:37