[XeTeX] Font protrusion --- new or old ?

Jonathan Kew jonathan at jfkew.plus.com
Sun Feb 8 15:36:16 CET 2009


On 8 Feb 2009, at 14:22, Stephen Moye wrote:

> On Feb 7, 2009, at 5:16 PM, Jonathan Kew wrote:
>
>> I wonder if a similar approach to hanging punctuation could be
>> implemented using \XeTeXinterchartoks, though; that might be less
>> intrusive as it doesn't involve making the characters active.
>
> Interesting... care to give a hint as to how that might work,  
> something
> to get me started?


Basically, borrow the ideas from Appendix D but use the transition  
between class 255 (non-character) and whatever classes you assign to  
the punctuation chars to insert the kerns. Beware of recursion.

%%!TEX TS-program = xetex
\font\tenrm="Times New Roman" at 10pt
\tenrm

\XeTeXinterchartokenstate=1
\XeTeXcharclass "201C = 10
\XeTeXcharclass "201D = 11
\newdimen\quotehang
\XeTeXinterchartoks 255 10 = {{\XeTeXinterchartokenstate=0
     \setbox0=\hbox{\char"201C}\quotehang=\wd0
     \ifhmode\kern\quotehang\vadjust{}\else\leavevmode\fi
     \kern-\quotehang}}
\XeTeXinterchartoks 11 255 = {{\XeTeXinterchartokenstate=0
     \setbox0=\hbox{\char"201D}\quotehang=\wd0
     \kern-\quotehang\kern\quotehang}}

\hsize=3.25in
\noindent
The one thing which I would note is that one can do this sort of thing
(to a certain degree) at the macro level — see Donald Knuth’s
description of “hanging punctuation” as “an easier problem” in The
\TeX{}book and Peter Wilson’s “hanging” package which enables this for
La\TeX.

\end





More information about the XeTeX mailing list