7

I am trying to typeset a poem with XeLaTeX using the IranNastaliq font, and I am running into problems with the glyphs rendered for many words. I have a PDF file I rendered from the same source tex file several years ago that is free of these problems.

A minimal example is shown below:

%!TEX TS-program-xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass{article}
\usepackage{fontspec}
\newfontfamily\farsifont[Script=Arabic,Scale=10]{IranNastaliq}

\begin{document}
\farsifont
{\huge نگار}
\end{document}

This produces the image on the left on my current setup (MacTeX BasicTeX 2014). The image on the right, on the other hand, is what gets rendered in other programs, such as TextEdit, and what I had rendered in the past using XeLaTeX on an older computer (also OS X).

Bad rendering of word Good rendering of word

What could be causing this problem? How would I debug this?

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Symbol 1 Apr 12 '15 at 2:02
  • 2
    I can reproduce the correct rendering on XeTeX 3.1415926-2.4-0.9998 (TeX Live 2012) and the incorrect rendering on XeTeX 3.14159265-2.6-0.99991 (TeX Live 2014). – syakhmi Apr 12 '15 at 2:18
  • I can confirm: the output with TL 2013 is like in the picture on the right. The change seems due to the switch to the HarfBuzz library. – egreg Apr 12 '15 at 9:42
4

The change does indeed seem to be due to the HarfBuzz library. I noticed the same "bad" version of the font's rendering in Chrome and Firefox, which both use HarfBuzz, while I saw the "good" version in applications that used Apple's native rendering.

I filed a bug with HarfBuzz, and the lead developer explained that this font makes use of contextual swashes cswh, which are not enabled by default in OpenType. More can be read about this and other OpenType features as they apply to Arabic fonts here: https://www.microsoft.com/typography/OpenTypeDev/arabic/intro.htm.

In the end I found I could fix the problem by manually enabling contextual swashes in my fontspec. A good guide to working with OpenType features in LaTeX can be found here: http://nitens.org/taraborelli/TeXOpenType.

\newfontfamily\farsifont[Script=Arabic,Scale=10,Contextuals=Swash]{IranNastaliq}

The good news is that as far as I can tell, there doesn't seem to be any bug here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.