I once tried to color ligatures for proofreading. I wanted them to stand out better. LaTeX automatically uses ligatures for ffl ffi and such combination of letters. However there are typesetting rules in German where the ligatures are not used. So to actually see where LaTeX inserted ligatures a discussion started on de.comp.text.tex lead to the idea of using Tex's virtual fonts to do the trick.
I managed to do this with the MiKTeX distribution back in 2006, so please bear with me if I don't get all the details right. Basically I changed the glyphs color per virtual fonts.
I used the command line tool vftovp
to convert the exisiting .vf
files into .vpl
files.
(virtual property lists) Via testfont /table
I checked which ligatures where available in the font and then changed their entries in the .vpl
file:
(CHARACTER O 33
(CHARWD R 0.777781)
(CHARHT R 0.683332)
(MAP
(SPECIAL pdf:direct: 1.0 0 0 rg)
(SETCHAR O 2)
(SPECIAL pdf:direct: 0 0 0 rg)
)
)
then compiled them via vptovf
back into .vf
files and then pdflatex
produced .pdfs
with colored ligatures. The two special commands switch the color to red and then back to black. This a very crude hack! But it worked back then. As the whole LaTeX font business is not for the faint-hearted it probably takes some experimenting with the current TeX-distributions.
If you have to create a new virtual font you choose a font you want as a base font. In your case the Hebrew font. As I don't know much about XeTeX I continue this example with a helvetica clone (phvr8r
).
tftopl phvr8r.tfm > myfont.vpl
should give you the human readable virtual property lists. Which can now be edited. For example the lines
(MAPFONT D 0 (FONTNAME phvr8r))
(MAPFONT D 1 (FONTNAME pcrr8r))
load phvr8r
(our base font) and pcrr8r
(Courier). Now you have to know which characters you want to change.
(CHARACTER O 65
(CHARWD R 0.8)
(MAP
(SELECTFONT D 1)
(SETCHAR O 045)
(MOVELEFT R 0.200)
(SELECTFONT D 0)
(SETCHAR O 051)
)
)
This picks character (octal 045
) from font 1
moves left a bit and picks character (octal 051
) from the other font. I don't know anything about the Hebrew fonts, but if the glyphs are combined like this you could intersperse commands for color changes like in the first example.
Then you create the virtual font (a .vf
and a .tfm
file) via
vptovf myfont
It's ready for use now. But the tricky part is often that within the TDS (TeX Directory Structure) the font files have to be in the right subdirectory to be found by TeX. And often the filename database (FNDB) of the TeX-distribution must be refreshed after this type of change.
I don't know if XeTeX knows something like plain-TeX, there a simple test file looks like this:
\font\myfont=myfont
\hsize 2in
\myfont
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis hendrerit dictum nisi
a suscipit. Proin velit arcu, tincidunt et gravida ac, pretium vel nunc. Suspendisse
scelerisque malesuada orci, quis volutpat diam ornare nec. Duis ligula est, posuere
non auctor ut, sodales elementum lacus. Nam egestas, diam et varius ornare, nisi
mauris posuere turpis, eu adipiscing diam mauris consequat nulla. Cras id lacus non
ante malesuada sodales.
\bye
With LaTeX and pdfLaTeX typically a pdftex.map
and the font definition files .fd
have to be adjusted or created. The best approach is to use the exisiting files from the base font and make small modifications to them to learn about all the pitfalls. The \pdfmapline
command could be of some use in the latex document to add your modified font.
The UK TeX FAQ has an entry about virtual fonts.
Best Answer
You can use the
xcolor
package. It provides\textcolor{<color>}{<text>}
as well as\color{<color>}
to switch the color for some give text or until the end of the group/environment. You can get different shades of gray by usingblack!x
as a color wherex
is a number from 0 to 100, taken as a percentage with 100 being black.