mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 15:02:11 +00:00
Bug 902762 pt 4 - Support for orientation:sideways-right when drawing vertical textruns. r=jdaggett
This commit is contained in:
parent
e46d88166d
commit
934e56f8da
@ -1887,6 +1887,32 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
fontParams.isVerticalFont =
|
||||
aOrientation == gfxTextRunFactory::TEXT_ORIENT_VERTICAL_UPRIGHT;
|
||||
|
||||
bool sideways = false;
|
||||
gfxPoint origPt = *aPt;
|
||||
if (aRunParams.isVerticalRun && !fontParams.isVerticalFont) {
|
||||
sideways = true;
|
||||
aRunParams.context->Save();
|
||||
gfxPoint p(aPt->x * aRunParams.devPerApp,
|
||||
aPt->y * aRunParams.devPerApp);
|
||||
const Metrics& metrics = GetMetrics(eHorizontal);
|
||||
// Adjust the matrix to draw the (horizontally-shaped) textrun with
|
||||
// 90-degree CW rotation, and adjust position so that the rotated
|
||||
// horizontal text (which uses a standard alphabetic baseline) will
|
||||
// look OK when juxtaposed with upright glyphs (rendered on a centered
|
||||
// vertical baseline). The adjustment here is somewhat ad hoc; we
|
||||
// should eventually look for baseline tables[1] in the fonts and use
|
||||
// those if available.
|
||||
// [1] http://www.microsoft.com/typography/otspec/base.htm
|
||||
aRunParams.context->SetMatrix(aRunParams.context->CurrentMatrix().
|
||||
Translate(p). // translate origin for rotation
|
||||
Rotate(M_PI / 2.0). // turn 90deg clockwise
|
||||
Translate(-p). // undo the translation
|
||||
Translate(gfxPoint(0, metrics.emAscent - metrics.emDescent) / 2));
|
||||
// and offset the (alphabetic) baseline of the
|
||||
// horizontally-shaped text from the (centered)
|
||||
// default baseline used for vertical
|
||||
}
|
||||
|
||||
nsAutoPtr<gfxTextContextPaint> contextPaint;
|
||||
if (fontParams.haveSVGGlyphs && !fontParams.contextPaint) {
|
||||
// If no pattern is specified for fill, use the current pattern
|
||||
@ -1975,6 +2001,11 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
|
||||
aRunParams.dt->SetTransform(oldMat);
|
||||
aRunParams.dt->SetPermitSubpixelAA(oldSubpixelAA);
|
||||
|
||||
if (sideways) {
|
||||
aRunParams.context->Restore();
|
||||
*aPt = gfxPoint(origPt.x, origPt.y + (aPt->x - origPt.x));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -616,8 +616,6 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
||||
params.paintSVGGlyphs = !aCallbacks || aCallbacks->mShouldPaintSVGGlyphs;
|
||||
params.dt = aContext->GetDrawTarget();
|
||||
|
||||
gfxPoint pt = aPt;
|
||||
|
||||
// synthetic bolding draws glyphs twice ==> colors with opacity won't draw
|
||||
// correctly unless first drawn without alpha
|
||||
BufferAlphaColor syntheticBoldBuffer(aContext);
|
||||
@ -638,6 +636,8 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
||||
}
|
||||
|
||||
GlyphRunIterator iter(this, aStart, aLength);
|
||||
gfxFloat advance = 0.0;
|
||||
|
||||
while (iter.NextRun()) {
|
||||
gfxFont *font = iter.GetGlyphRun()->mFont;
|
||||
uint32_t start = iter.GetStringStart();
|
||||
@ -648,22 +648,29 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
||||
|
||||
bool drawPartial = aDrawMode == DrawMode::GLYPH_FILL ||
|
||||
(aDrawMode == DrawMode::GLYPH_PATH && aCallbacks);
|
||||
gfxPoint origPt = aPt;
|
||||
|
||||
if (drawPartial) {
|
||||
DrawPartialLigature(font, start, ligatureRunStart, &pt,
|
||||
DrawPartialLigature(font, start, ligatureRunStart, &aPt,
|
||||
aProvider, params,
|
||||
iter.GetGlyphRun()->mOrientation);
|
||||
}
|
||||
|
||||
DrawGlyphs(font, ligatureRunStart, ligatureRunEnd, &pt,
|
||||
DrawGlyphs(font, ligatureRunStart, ligatureRunEnd, &aPt,
|
||||
aProvider, ligatureRunStart, ligatureRunEnd, params,
|
||||
iter.GetGlyphRun()->mOrientation);
|
||||
|
||||
if (drawPartial) {
|
||||
DrawPartialLigature(font, ligatureRunEnd, end, &pt,
|
||||
DrawPartialLigature(font, ligatureRunEnd, end, &aPt,
|
||||
aProvider, params,
|
||||
iter.GetGlyphRun()->mOrientation);
|
||||
}
|
||||
|
||||
if (params.isVerticalRun) {
|
||||
advance += (aPt.y - origPt.y) * params.direction;
|
||||
} else {
|
||||
advance += (aPt.x - origPt.x) * params.direction;
|
||||
}
|
||||
}
|
||||
|
||||
// composite result when synthetic bolding used
|
||||
@ -672,11 +679,7 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, DrawMode aDrawMode,
|
||||
}
|
||||
|
||||
if (aAdvanceWidth) {
|
||||
if (params.isVerticalRun) {
|
||||
*aAdvanceWidth = (pt.y - aPt.y) * params.direction;
|
||||
} else {
|
||||
*aAdvanceWidth = (pt.x - aPt.x) * params.direction;
|
||||
}
|
||||
*aAdvanceWidth = advance;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user