[XeTeX] STFangsong punctuation kerning
Jonathan Kew
jonathan_kew at sil.org
Mon Jun 12 22:32:20 CEST 2006
On 12 Jun 2006, at 5:41 pm, Likai Liu wrote:
> Thanks to all who responded.
>
> I found a way to manage lists in TeXbook Appendix D, Dirty Tricks
> (it's actually kind of neat!),
Yes, Appendix D can repay some careful study! :)
> so I was able to push the scalability part a bit further, but it
> took so much effort to rewrite the macros. I'm a bit baffled by how
> there isn't an easier way to do this, but I feel fortunate that
> with some programming genius, this can actually be done in TeX. I
> don't expect this flexibility in other typesetting systems.
>
> I agree with Jonathan that the kosher way to do this is to use
> contextual alternate glyph substitution, but I suppose this is only
> implemented in more expensive fonts, and not those that came with
> Mac OS X.
I'm not aware of *any* fonts where it is implemented, although it
certainly could be -- the underlying font technology provides
suitable mechanisms, if a vendor cared to do it.
> Another question: the following code detects the "fullwidth" of a
> block character, but this only works for a given point size.
>
> \newbox\fullspace
> \setbox\fullspace=\hbox{ }% this is a full-width space character
>
> \newdimen\fullwidth \fullwidth=\wd\fullspace
> \newdimen\halfwidth \halfwidth=0.5\wd\fullspace
>
> Is there a way to extend this for all font point sizes, like in the
> fashiong of em and ex units? (note: 1ex != \halfwidth)
Not really; TeX doesn't let you define new units.
The "halfwidth" dimension will scale in direct proportion with the
"em" unit, so you could compute the ratio between 1em and \wd
\fullspace, and then use this as a multiplier whenever you want a
dimension based on the character width. But this ratio will not
necessarily be the same for different fonts, so you'd still have to
do the computation for each font you use.
I suppose one approach would be to compute \wd\fullspace right after
loading each Chinese font, and then store the result in a new
\fontdimen, or even overwrite one of the standard ones that is
irrelevant (such as the ex-height, perhaps, if you aren't going to be
using \accent with this font). For example:
\font\X="STFangsong" at 16pt
\setbox0=\hbox{\X\char"3000}
\fontdimen9\X=\wd0 % fontdimens 1-8 are already assigned a
meaning, so it may be best not to re-use them
Now \fontdimen9\X is the width of the "ideographic space" (fullwidth
space) in this font; and if you do the same thing each time you load
a Chinese font, you can use "\fontdimen9\font" whenever you need this
value for the font currently in use. So then "\kern0.5\fontdimen9
\font" will give you a "half-width" kern, etc.
JK
More information about the XeTeX
mailing list