[core] Render half-width glyphs in upright orientation

This change forces glyphs whose natural orientation in vertical writing
mode is 'sideways' to be rendered in upright orientation (only for non complex
text layouts). This is different compared to W3C / browser behavior that is by
default, renders glyphs in their respective natural orientation.

In the future, there  might need to add a new layout property that would control
glyph orientation separately (e.g., text-glyph-orientation: natural | upright).
This commit is contained in:
Alexander Shalamov
2019-08-04 14:44:22 +03:00
parent 03bb17f8c5
commit 1b9d4d792c
6 changed files with 31 additions and 8 deletions

View File

@@ -160,7 +160,11 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
const Point<float> center{ -halfAdvance, halfAdvance - Shaping::yOffset };
const float verticalRotation = -M_PI_2;
const Point<float> xOffsetCorrection{ 5.0f - Shaping::yOffset, 0.0f };
// xHalfWidhtOffsetcorrection is a difference between full-width and half-width
// advance, should be 0 for full-width glyphs and will pull up half-width glyphs.
const float xHalfWidhtOffsetcorrection = util::ONE_EM / 2 - halfAdvance;
const Point<float> xOffsetCorrection{ 5.0f - Shaping::yOffset - xHalfWidhtOffsetcorrection, 0.0f };
tl = util::rotate(tl - center, verticalRotation) + center + xOffsetCorrection + verticalizedLabelOffset;
tr = util::rotate(tr - center, verticalRotation) + center + xOffsetCorrection + verticalizedLabelOffset;