#64

How to: Vertical text?

Openclembuopened 6mo ago

This is likely a very broad feature request. To avoid a Y-not-X problem, I'd rather ask about how to solve the problem at hand rather than asking for specific solutions.

I'm trying to find a way to render vertical text, and it's coming clearer by the minute that I can't simply render horizontal runs and rotate them. Some scripts are vertical-by-default, some should have rotated glyphs when going from horizontal to vertical, some don't...

The version of kbts I'm using has this line somewhere: https://github.com/JimmyLefevre/kb/blob/854bcba6f9dfafc36ec7e5a662de2506b20a5a03/kb_text_shape.h#L22666

Which, I assume, means that it doesn't handle vertical text at all?

Let's say I'd like to shape this following text: 「日本語」 Laid out vertically, the corner quote brackets would need to be rotated, but the character glyphs wouldn't. And, I say that assuming a square bounding space, but if the font defines different glyphs for horizontal and vertical brackets, then I can't just rotate the glyphs. I'd have to interrogate the font for it, which is what I've been using kbts for from the start.

Do you have an idea of how much work it'd be to add vertical text support?

Activity

1
JimmyLefevre4mo ago

That is correct, we do not handle vertical text right now.

Your intuition is correct that a font may decide to use altogether different glyphs in vertical mode, through the vert feature. I'd have to add a new op list for vertical mode that includes it and disables a bunch of horizontal-only features (like kern). Beyond that, I'd potentially need to modify all the code that assumes X is the main axis, or maybe consider that "X" just means "main axis" internally and swap Xs and Ys at the end if I can make it work.

I don't think this would be very complicated, I just haven't needed it personally so I haven't gotten around to it yet.