I was investigating how to typeset vertical Chinese text. I cannot understand how XeTeX rotates glyph when the font is loaded with the vertical
specifier. The following plain XeTeX MWE illustrates my problem:
\font\chinesefont="Source Han Serif SC:vertical" at 10pt
\setbox0\hbox{\chinesefont \char"4E00 }% CJK ideograph `one'
\the\wd0\ %
\the\ht0\ %
\the\dp0\ %
\box0 %
\setbox0\hbox{\chinesefont AHIO\char"5B57 }% CJK ideograph `letter'
\box0 %
\bye
Some explanations are needed for the screenshot above:
- A red straight line is drawn to mark the baseline.
- The ideograph U+4E00 is correctly rotated 90 degrees counterclockwise, and it clearly extends below the baseline. Yet the box containing it has a depth of zero. In fact, if we look at the pre-rotated U+4E00 glyph, we would see that it sits above the baseline and has a height of 5.14pt. This means, when XeTeX finishes rotating the glyph, the resulting box has height and depth that are from the pre-rotated glyph.
- The characters U+4E00, cap A, cap H, cap I, cap O and U+5B57 are all rendered in
Source Han Serif SC:vertical
. All of them have the same “horizontal” advance of 10.0pt, and they are center-aligned around the red baseline (I deliberately choose symmetrical and proportional cap letters to show this effect).
My questions are the following:
- Regarding Item 2, are the “wrong” box dimensions bugs/features? Should I report this to the XeTeX repo? If the engine does not fixed this, can it be fixed at the macro level?
- Regarding Item 3, I should state that centering all rotated glyphs around a common axis is the correct way to do vertical layout. However, the axis is the original baseline, which causes the rotated text not being “aligned” with the non-rotated text. A better “centering axis” is 0.38em above the original baseline (this makes the rotated ideograph to have a depth of 0.12em, which is the intended design of Source Han Serif). Can we configure this centering axis to be 0.38em above the baseline automatically, either via an XeTeX primitive or via macros?
Something like this (but the bounding boxes are a mess):
\font\chinesefont="Source Han Serif SC:vertical" at 10pt
Better alignment
\raise0.38em\hbox{\chinesefont \char"4E00 \char"5B57 }
Bad metrics
\bye
\font\chinesefont="Source Han Serif SC:vertical;+vert" at 10pt
, or thefontspec
equivalent\fontspec{Source Han Serif SC}[RawFeature=vertical,Vertical=Alternates]
in LaTeX. But let’s focus on the XeTeX featurevertical
for now, not the OpenType featurevert
.xeCJK
package may already be doing that, since its non-rotated ("abc") text appears in the usual printed location (on the baseline), with the rotated text shifted "up" ("rightwards") by an amount that looks like your recommendation, to give that "depth".xeCJK
’s hooks are very slow: They essentially box every CJK letters and CJK punctuation marks and then shift them one by one. Furthermore, the bounding boxes are still “wrong”. My question focuses on XeTeX’s low-level behavior and asks for a more direct solution (so to speak).