[webkit-dev] vertical text
hyatt at apple.com
Mon Nov 14 12:57:36 PST 2011
On Nov 11, 2011, at 7:59 AM, Cary Clark wrote:
> Thanks for the answer, Dave. That makes perfect sense.
> Why is it that the graphics context is rotated but the advances supplied to Font::DrawGlyphs in the GlyphBuffer aren't?
Right now fonts are broken up into two categories: ones that are considered "vertical" and ones that are considered "horizontal", but a "vertical" font uses a text-orientation-specific fallback when the glyphs are known to have flexible orientation, e.g., they could render upright or sideways depending on the value of the text-orientation property.
The default value of text-orientation is vertical-right, meaning that these flexibly oriented glyphs should render rotated in a vertical text environment.
However, because we rotated the graphics context, we are able to simply use the horizontal version of the font data in this case, and this allows us to reduce memory usage and re-use all the cached horizontal font information. Therefore the flexible glyph advances are unrotated and are just the horizontal font data information.
Instead we rotate the glyphs that are always locked to an upright orientation in a vertical text environment. Those advances are the ones that are rotated. In effect you have a double rotation (the graphics context rotates, and then the inflexible glyphs get rotated again when drawing).
This may seem backwards and somewhat confusing, but I can assure you we'd have to write way more code if we flipped things around (and we'd consume 2x the memory for glyph width storage for English letters).
(hyatt at apple.com)
More information about the webkit-dev