summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/FontAndroid.cpp
diff options
context:
space:
mode:
authorclaireho <chinglanho@gmail.com>2011-10-12 18:37:58 -0700
committerclaireho <chinglanho@gmail.com>2011-10-17 10:15:59 -0700
commit295fd960c28a38cfa7a28d4b8f68f474394f7fb0 (patch)
tree0b67dc5791e552085f96df636b453745b9b0e48f /Source/WebCore/platform/graphics/android/FontAndroid.cpp
parentc13fe17594dff1d9e702affd7cba2561d6fa3bef (diff)
downloadexternal_webkit-295fd960c28a38cfa7a28d4b8f68f474394f7fb0.zip
external_webkit-295fd960c28a38cfa7a28d4b8f68f474394f7fb0.tar.gz
external_webkit-295fd960c28a38cfa7a28d4b8f68f474394f7fb0.tar.bz2
Reapply CL for "Vertical Writing Mode" support.
Bug 5094208 - Browser does not handle Japanese text in vertical writing mode. This changeset syncs up with Chrome's implementation for vertical text rendering. It 1. Adds fontOrientation and textOrientation to FontPlatformData. 2. Rotates the text in drawGlyphs for vertical writing mode. Here are the changesets for Chrome's vertical writinig mode support: 1. http://trac.webkit.org/changeset/74232 2. http://trac.webkit.org/changeset/80610 3. http://trac.webkit.org/changeset/80654 This CL re-applies reverted CL136684(https://android-git.corp.google.com/g/#/c/136684/). CL136684 was rollbacked because 2 constructors in FontPlatformDataAndroid.cpp did not have the init for fontOrientation and textOrientation. That caused the inconsistent comparison while FontCache.cpp tries to get the cached font and falls into an infinite loop in HashTable.h:656 Change-Id: I45700dcc8c9266e1b5ae8e588205f24825ca4317
Diffstat (limited to 'Source/WebCore/platform/graphics/android/FontAndroid.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/FontAndroid.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
index 6b4296b..3528d47 100644
--- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
@@ -183,8 +183,10 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
SkScalar y = SkFloatToScalar(point.y());
const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
- SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
+ SkAutoSTMalloc<32, SkPoint> storage(numGlyphs), storage2(numGlyphs), storage3(numGlyphs);
SkPoint* pos = storage.get();
+ SkPoint* vPosBegin = storage2.get();
+ SkPoint* vPosEnd = storage3.get();
SkCanvas* canvas = gc->platformContext()->mCanvas;
@@ -221,12 +223,27 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
localCount * sizeof(uint16_t),
&pos[localIndex], paint);
} else {
+ bool isVertical = font->platformData().orientation() == Vertical;
for (int i = 0; i < numGlyphs; i++) {
pos[i].set(x, y);
- x += SkFloatToScalar(adv[i].width());
y += SkFloatToScalar(adv[i].height());
+ if (isVertical) {
+ SkScalar myWidth = SkFloatToScalar(adv[i].width());
+ vPosBegin[i].set(x + myWidth, y);
+ vPosEnd[i].set(x + myWidth, y - myWidth);
+ x += myWidth;
+
+ SkPath path;
+ path.reset();
+ path.moveTo(vPosBegin[i]);
+ path.lineTo(vPosEnd[i]);
+ canvas->drawTextOnPath(glyphs + i, 2, path, 0, paint);
+ }
+ else
+ x += SkFloatToScalar(adv[i].width());
}
- canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
+ if (!isVertical)
+ canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
}
}