Reputation: 4770
I'm currently rendering text with FreeType + Harfbuzz and am now trying to introduce vertical text rendering (mainly for east asian scripts).
The issue I'm facing is that I can't figure out how wide a column of text should be. For horizontal text we can find out the line height with ascent - descent
, but since these values are not provided in the case of vertical text ('ascent' / 'descent' is simple the left and right part of the glyph respectively) I have no idea how wide my text columns should be.
I tried using bbox width for the font, but the box changes drastically between different fonts, giving no good info.
Upvotes: 3
Views: 393
Reputation: 37
I think this site may be useful :
I think it might be a case of trial and error, however you could also try these steps:
Get a run of vertical text and feed it into Harfbuzz to get the glyphs and glyph positions
Take the resulting glyph positions and adjust them using the values from hb_font_subtract_glyph_origin_for_direction
The top-side bearing from the vmtx table should be subtracted from the y-position of each glyph
The maximum y extent of each glyph should then be subtracted from the y- position of each glyph
The x position should be further adjusted by vertTypoDescender from the vmtx table if I want a central baseline
Draw the glyphs at those positions
Upvotes: 0