{"id":3079,"date":"2013-08-15T11:18:52","date_gmt":"2013-08-15T11:18:52","guid":{"rendered":"http:\/\/www.readytext.co.uk\/?p=3079"},"modified":"2013-11-28T07:44:41","modified_gmt":"2013-11-28T07:44:41","slug":"colouring-arabic-vowels-with-xetex-and-a-harfbuzz-pre-processor","status":"publish","type":"post","link":"https:\/\/www.readytext.co.uk\/?p=3079","title":{"rendered":"Colouring Arabic vowels with XeTeX and a HarfBuzz pre-processor"},"content":{"rendered":"<h1>Introduction<\/h1>\n<p>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&#8217;s a simple example of colouring Arabic vowels &ndash; this example is likely to be possible with XeTeX alone, but it&#8217;s just a quick demo &ndash; 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 &ndash; it&#8217;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. <\/p>\n<h2>My test document<\/h2>\n<p><code>\\documentclass[11pt,twoside,a4paper]{book}<br \/>\n\\pdfpageheight=297mm<br \/>\n\\pdfpagewidth=210mm<br \/>\n\\usepackage{fontspec}<br \/>\n\\usepackage{bidi}<br \/>\n\\begin{document}<br \/>\n\\pagestyle{empty}<br \/>\n\\font\\scha= \"Scheherazade\" at 12bp<br \/>\n\\font\\schb= \"Scheherazade\" at 30bp<br \/>\n\\scha \\noindent Here, we compare the Arabic text contained in our \\XeTeX\\  file to the text which is<br \/>\noutput directly via a HarfBuzz pre-processor and input into our document from \"harfarab.tex\"\\par\\vskip10pt<br \/>\n\\schb<br \/>\n\\noindent \\hbox to 150pt{Actual text:\\hfill} \\RL{\u0647\u064e\u0645\u0652\u0632\u064e\u0629 \u0648\u064e\u0635\u0652\u0644}\\par<br \/>\n\\noindent \\hbox to 150pt{Processed text:\\hfill} \\input harfarab.tex<br \/>\n\\end{document}<\/code><\/p>\n<h2>harfarab.tex output via HarfBuzz<\/h2>\n<p>Displayed here on individual lines for readability.<\/p>\n<p><code>\\XeTeXglyph609<br \/>\n\\hbox to 0pt{\\vbox{\\moveright 6.53bp\\hbox{\\raise-2.71bp\\hbox{\\special{color push rgb 0 0 1}\\XeTeXglyph911 \\special{color pop}}}}}<br \/>\n\\XeTeXglyph831<br \/>\n\\hbox to 0pt{\\vbox{\\moveright 3.56bp\\hbox{\\raise-4.82bp\\hbox{\\special{color push rgb 0 0 1}\\XeTeXglyph907 \\special{color pop}}}}}<br \/>\n\\XeTeXglyph263<br \/>\n\\XeTeXglyph3<br \/>\n\\XeTeXglyph436<br \/>\n\\hbox to 0pt{\\vbox{\\moveright 1.82bp\\hbox{\\raise-3.24bp\\hbox{\\special{color push rgb 0 0 1}\\XeTeXglyph907 \\special{color pop}}}}}<br \/>\n\\XeTeXglyph489<br \/>\n\\hbox to 0pt{\\vbox{\\moveright 3.47bp\\hbox{\\raise-4.35bp\\hbox{\\special{color push rgb 0 0 1}\\XeTeXglyph911 \\special{color pop}}}}}<br \/>\n\\XeTeXglyph755<br \/>\n\\hbox to 0pt{\\vbox{\\moveright 2.20bp\\hbox{\\raise-2.64bp\\hbox{\\special{color push rgb 0 0 1}\\XeTeXglyph907 \\special{color pop}}}}}<br \/>\n\\XeTeXglyph896<\/code> <\/p>\n<h2>The resulting PDF<\/h2>\n<p>As you can see, the results are identical &ndash; as you&#8217;d expect since they both use the HarfBuzz engine, one internally to XeTeX, the other externally in a pre-processor.<\/p>\n<p><a href=\"http:\/\/readytext.co.uk\/files\/harfbuzz.pdf\">Download PDF<\/a><\/p>\n<p><iframe src=\"https:\/\/docs.google.com\/gview?url=http:\/\/readytext.co.uk\/files\/\/harfbuzz.pdf&#038;embedded=true\" style=\"width:100%; height:300px;\" frameborder=\"0\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s a simple example of colouring Arabic vowels &ndash; this example is likely to be possible with XeTeX alone, but it&#8217;s just a quick demo &ndash; many other interesting possibilities come [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,28,16,10,17],"tags":[],"class_list":["post-3079","post","type-post","status-publish","format-standard","hentry","category-arabic","category-c-programming-miscellaneous","category-typesetting-and-algorithms","category-unicode","category-unicode-arabic"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3079"}],"version-history":[{"count":18,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3079\/revisions"}],"predecessor-version":[{"id":3210,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3079\/revisions\/3210"}],"wp:attachment":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}