[XeTeX] showhyphens and fontspec

Jonathan Kew jonathan_kew at sil.org
Thu Sep 21 19:31:24 CEST 2006


On 21 Sep 2006, at 2:41 pm, Pablo Rodríguez wrote:

> For some reason unknown to me, \showhyphens is not able to display
> hyphens when \setromanfont is selected.
>
> \documentclass{article}
> \usepackage[spanish]{babel}
> \usepackage{fontspec}
> \setromanfont{Palatino Linotype}
> \begin{document}
> \showhyphens{semana}
> \end{document}
>
> If you comment the fourth line out, hyphens will be displayed.
>
> Is it possible to solve this?

Yes; this is a known issue. The technique used by the \showhyphens  
macro from plain.tex will not display hyphen positions when used with  
"native" fonts in xetex.

It's possible to redefine the macro so that it will display the  
breaks; here's a version you could try:

%---------------------
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{fontspec}
\setromanfont{Times Roman}

\def\showhyphens#1{%
   \setbox0=\vbox{\hsize1sp \hbadness10000 \hfuzz\maxdimen
     \everypar={} \leftskip0pt \rightskip\leftskip \pretolerance-1
     \noindent \hskip0pt #1\par
     \global\setbox1=\hbox{}\SHconcatenate}%
   \setbox0=\hbox to \maxdimen{\unhbox1}}
\def\SHconcatenate{\unskip\unpenalty
   \setbox0=\lastbox \ifvoid0 \let\next\relax \else
     \global\setbox1=\hbox{\unhbox0
     \unskip\unskip\unhbox1}\let\next\SHconcatenate
   \fi\next}

\begin{document}
\showhyphens{semana}
\end{document}
%---------------------

This works OK for individual words; if you try putting multiple words  
in a single \showhyphens, you'll see the hyphen positions but the  
word spaces will disappear. Fixing this is left as an exercise for  
the macro wizards out there. :)

JK



More information about the XeTeX mailing list