15Aug/13Off

# Introduction

Using an external pre-processor (built using HarfBuzz) you can achieve affects that are not possible (or, at least, not easy) directly with XeTeX. Here's a simple example of colouring Arabic vowels – this example is likely to be possible with XeTeX alone, but it's just a quick demo – many other interesting possibilities come to mind. At the moment the Arabic string is hardcoded into the pre-processor, just for testing, but I plan to make it read from files output by XeTeX – it's just a proof of concept. The vowel positioning was achieved by putting the vowel glyphs in boxes and shifting them according to the anchor point data provided by HarfBuzz.

## My test document

\documentclass[11pt,twoside,a4paper]{book} \pdfpageheight=297mm \pdfpagewidth=210mm \usepackage{fontspec} \usepackage{bidi} \begin{document} \pagestyle{empty} \font\scha= "Scheherazade" at 12bp \font\schb= "Scheherazade" at 30bp \scha \noindent Here, we compare the Arabic text contained in our \XeTeX\ file to the text which is output directly via a HarfBuzz pre-processor and input into our document from "harfarab.tex"\par\vskip10pt \schb \noindent \hbox to 150pt{Actual text:\hfill} \RL{هَمْزَة وَصْل}\par \noindent \hbox to 150pt{Processed text:\hfill} \input harfarab.tex \end{document}

## harfarab.tex output via HarfBuzz

Displayed here on individual lines for readability.

\XeTeXglyph609 \hbox to 0pt{\vbox{\moveright 6.53bp\hbox{\raise-2.71bp\hbox{\special{color push rgb 0 0 1}\XeTeXglyph911 \special{color pop}}}}} \XeTeXglyph831 \hbox to 0pt{\vbox{\moveright 3.56bp\hbox{\raise-4.82bp\hbox{\special{color push rgb 0 0 1}\XeTeXglyph907 \special{color pop}}}}} \XeTeXglyph263 \XeTeXglyph3 \XeTeXglyph436 \hbox to 0pt{\vbox{\moveright 1.82bp\hbox{\raise-3.24bp\hbox{\special{color push rgb 0 0 1}\XeTeXglyph907 \special{color pop}}}}} \XeTeXglyph489 \hbox to 0pt{\vbox{\moveright 3.47bp\hbox{\raise-4.35bp\hbox{\special{color push rgb 0 0 1}\XeTeXglyph911 \special{color pop}}}}} \XeTeXglyph755 \hbox to 0pt{\vbox{\moveright 2.20bp\hbox{\raise-2.64bp\hbox{\special{color push rgb 0 0 1}\XeTeXglyph907 \special{color pop}}}}} \XeTeXglyph896

## The resulting PDF

As you can see, the results are identical – as you'd expect since they both use the HarfBuzz engine, one internally to XeTeX, the other externally in a pre-processor.