diff options
author | Derek Sollenberger <djsollen@google.com> | 2012-03-14 11:10:56 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2012-03-14 11:10:56 -0400 |
commit | 916ae1fb7445b6b919a72f195721d8dc09ddb1fc (patch) | |
tree | e7c48f87c953ee55ec8b7cdfea37b6db655e92e4 /Source/WebCore/platform/graphics/android/FontAndroid.cpp | |
parent | 5df0c86c85cb70113118a1d77ea868e3691ea926 (diff) | |
download | external_webkit-916ae1fb7445b6b919a72f195721d8dc09ddb1fc.zip external_webkit-916ae1fb7445b6b919a72f195721d8dc09ddb1fc.tar.gz external_webkit-916ae1fb7445b6b919a72f195721d8dc09ddb1fc.tar.bz2 |
Draw vertical text using by setting verticalText flag in SkPaint.
This approach replaces drawing each vertical character on a Path.
The use of the verticalText flag requires an update to Skia's
freetype implementation which in external/skia.
bug: 5558851
Change-Id: If33288c348e3c51df2d8edc1ee4352de0ac521df
Diffstat (limited to 'Source/WebCore/platform/graphics/android/FontAndroid.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/FontAndroid.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp index ef7740c..9fa16b6 100644 --- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp @@ -88,6 +88,8 @@ static bool setupForText(SkPaint* paint, GraphicsContext* gc, if (!mode) return false; + paint->setVerticalText(font->platformData().orientation() == Vertical); + FloatSize shadowOffset; float shadowBlur; Color shadowColor; @@ -193,8 +195,6 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, const GlyphBufferAdvance* adv = glyphBuffer.advances(from); 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; @@ -202,6 +202,9 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, point.xy + [width, height, width, height, ...], so we have to convert */ + if (font->platformData().orientation() == Vertical) + y += SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent()); + if (EmojiFont::IsAvailable()) { // set filtering, to make scaled images look nice(r) paint.setFilterBitmap(true); @@ -231,27 +234,25 @@ 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); 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()); + x += SkFloatToScalar(adv[i].width()); } - if (!isVertical) - canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); + + if (font->platformData().orientation() == Vertical) { + canvas->save(); + canvas->rotate(-90); + SkMatrix rotator; + rotator.reset(); + rotator.setRotate(90); + rotator.mapPoints(pos, numGlyphs); + } + + canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); + + if (font->platformData().orientation() == Vertical) + canvas->restore(); } } |