Here's a sample file I've been using to look at the effect of this locally. Based on what I see here, I think we probably want to tweak things a bit further. Observations...
With current trunk code (i.e. without this patch), the
auto position of the underline looks fine, and the
text-underline-offset:0px position looks perfect in horizontal mode (it exactly touches the alphabetic baseline). In
sideways-* writing modes, the result looks exactly like the horizontal result, just rotated by 90°, which is what I'd expect. In
vertical-* modes, the
text-underline-offset:0px position is centered, which is bad, and is what we primarily want to fix here.
With this patch applied, the
vertical-* modes is much better. (It's hard to say what the exact "correct" position would be, but the result here looks reasonable to me.) However, in
sideways-* modes, the position has been shifted slightly, such that it's now fractionally away from the alphabetic baseline -- there's a 1px gap or thereabouts. This seems regrettable; those cases looked perfect previously. Can we make sure the fix here only affects
vertical-* modes, and leaves the
sideways-* modes unchanged?
The other thing this example highlights (although it's not a new issue in this patch) is that
text-underline-offset doesn't have any effect in vertical mode when
lang=ja is in effect, when the underline appears by default to the right of the text. This is probably because we handle this internally by effectively swapping under- and over-line decorations at some point, but I think we need to fix this:
text-underline-offset should work similarly for all languages and writing modes.