# Proper outline in Devanagari and Arabic fonts

Please save your time and energy on this question, I also submitted one possible solution.

Zdeněk Wagner, a Czech TeXist, in his article (the Zpravodaj journal of the Czechoslovak TeX Users Group, 1/2013) mentions a problem of getting proper outline font, e.g. for Devanagari and Arabic fonts, by using the \pdfliteral command. This is an example and a preview typeset in the CODE2000.TTF font.

The problem is that we actually see how glyphs are put together, see picture on left, the correct form is shown in picture on right. How to get from the left picture to the right one? Why this example is running with lualatex, but not with xelatex?

%! {xe|lua}latex mal-deva.tex
%   xelatex is not working, lualatex does work
\documentclass[a4paper]{article}
\pagestyle{empty}\parindent=0pt
\usepackage{fontspec}
\usepackage{xltxtra}
\begin{document}
\huge
% http://web.archive.org/web/20101122142710/http://code2000.net/CODE2000.ZIP
\setmainfont[ExternalLocation]{CODE2000.TTF}%
\def\malword{देवनागरी}% Term in English: Devanagari
\pdfliteral page {q 2 Tr 0.7 w 0 0 1 0 k 1 0 1 .1 K}
\malword
\pdfliteral page {Q}
\end{document}


• I've never had much luck running XeLaTeX code, but I tried to do it here, because your problem looks interesting. I downloaded/installed CODE2000.ttf, and when I ran your MWE under XeLaTEX (MikTeX installation), I get the error ! Undefined control sequence. l.10 \pdfliteral page {q 2 Tr 0.7 w 0 0 1 0 k 1 0 1 .1 K}\malword\pdfliteral{Q} . Is there something simple I am doing wrong? – Steven B. Segletes Apr 4 '14 at 23:35
• @Steven Yes, it does not work with xelatex but it works with lualatex. I am updating the question as well as my answer. – Malipivo Apr 5 '14 at 5:21

I am using two steps. First, I draw an outline of the font and I put the font on it in the second step. There is \pdfliteral command in use, it doesn't work with xelatex, we must change it to the \special{pdf: code form. Because there is a different settings for left-to-right and right-to-left typesetting in xelatex and lualatex, I needed to use l and r in that \makebox command according to the used format.

The only remaining problem of this method is that we are losing a half of the outline width (the inner part), but we could partly fix and preserve the width of outline by changing the w parameter manually, let's say from 0.7 to 1.0 (in theory to 1.4). I enclose one possible solution to this problem.

%! {xe|lua}latex mal-deva-solution.tex
\documentclass[a4paper]{article}
\pagestyle{empty}\parindent=0pt
\usepackage{fontspec}
\begin{document}
\huge
% http://web.archive.org/web/20101122142710/http://code2000.net/CODE2000.ZIP
\setmainfont[ExternalLocation]{CODE2000.TTF}%
\def\malword{देवनागरी}% In English: Devanagari
\special{pdf: code q 2 Tr 0.7 w 0 0 1 0 k 1 0 1 .1 K}%
%\pdfliteral page {q 2 Tr 0.7 w 0 0 1 0 k 1 0 1 .1 K} % An alternative for lualatex...
\malword
\special{pdf: code Q}%
%\pdfliteral page {Q} % An alternative for lualatex...
\newpage
\ifpdf
\def\malside{r}%
\else
\def\malside{l}%
\fi
\makebox[0pt][\malside]{%
\special{pdf: code q 1 Tr 0.7 w 0 0 1 0 k 1 0 1 .1 K}%
%\pdfliteral page {q 1 Tr 0.7 w 0 0 1 0 k 1 0 1 .1 K}% An alternative for lualatex...
\malword
\special{pdf: code Q}% An alternative for lualatex...
%\pdfliteral page {Q}
}%
\special{pdf: code q 0 Tr 0 0 1 0 k}%
%\pdfliteral page {q 0 Tr 0 0 1 0 k} % An alternative for lualatex...
\malword
\special{pdf: code Q}%
%\pdfliteral page {Q} % An alternative for lualatex...
\end{document}