diff options
author | Raph Levien <raph@google.com> | 2014-06-11 21:18:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-06-10 22:18:15 +0000 |
commit | c2362db2de86813da50fe327f41ce3ee927207ef (patch) | |
tree | d025be3c1bfc4e3dc056f0f0c39b62103ce79a2b | |
parent | 707a525cfa16769dd50952aa5caddb01833807f8 (diff) | |
parent | 3333f75818e6fe0af55130083bd8461ef806c1f2 (diff) | |
download | frameworks_base-c2362db2de86813da50fe327f41ce3ee927207ef.zip frameworks_base-c2362db2de86813da50fe327f41ce3ee927207ef.tar.gz frameworks_base-c2362db2de86813da50fe327f41ce3ee927207ef.tar.bz2 |
Merge "Support fake italics" into lmp-preview-dev
-rw-r--r-- | core/jni/android/graphics/MinikinSkia.cpp | 6 | ||||
-rw-r--r-- | core/jni/android/graphics/MinikinUtils.h | 6 | ||||
-rw-r--r-- | core/jni/android/graphics/Paint.cpp | 9 |
3 files changed, 19 insertions, 2 deletions
diff --git a/core/jni/android/graphics/MinikinSkia.cpp b/core/jni/android/graphics/MinikinSkia.cpp index a0796c6..25eb941 100644 --- a/core/jni/android/graphics/MinikinSkia.cpp +++ b/core/jni/android/graphics/MinikinSkia.cpp @@ -118,8 +118,10 @@ void MinikinFontSkia::unpackPaintFlags(SkPaint* paint, uint32_t paintFlags) { void MinikinFontSkia::populateSkPaint(SkPaint* paint, const MinikinFont* font, FontFakery fakery) { paint->setTypeface(reinterpret_cast<const MinikinFontSkia*>(font)->GetSkTypeface()); - paint->setFakeBoldText(fakery.isFakeBold()); - // TODO: fake italics + paint->setFakeBoldText(paint->isFakeBoldText() || fakery.isFakeBold()); + if (fakery.isFakeItalic()) { + paint->setTextSkewX(paint->getTextSkewX() - 0.25f); + } } } diff --git a/core/jni/android/graphics/MinikinUtils.h b/core/jni/android/graphics/MinikinUtils.h index 47ab616..a96c6b1 100644 --- a/core/jni/android/graphics/MinikinUtils.h +++ b/core/jni/android/graphics/MinikinUtils.h @@ -39,6 +39,8 @@ public: // f is a functor of type void f(size_t start, size_t end); template <typename F> static void forFontRun(const Layout& layout, SkPaint* paint, F& f) { + float saveSkewX = paint->getTextSkewX(); + bool savefakeBold = paint->isFakeBoldText(); MinikinFont* curFont = NULL; size_t start = 0; size_t nGlyphs = layout.nGlyphs(); @@ -47,6 +49,8 @@ public: if (i > 0 && nextFont != curFont) { MinikinFontSkia::populateSkPaint(paint, curFont, layout.getFakery(start)); f(start, i); + paint->setTextSkewX(saveSkewX); + paint->setFakeBoldText(savefakeBold); start = i; } curFont = nextFont; @@ -54,6 +58,8 @@ public: if (nGlyphs > start) { MinikinFontSkia::populateSkPaint(paint, curFont, layout.getFakery(start)); f(start, nGlyphs); + paint->setTextSkewX(saveSkewX); + paint->setFakeBoldText(savefakeBold); } } }; diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index 74f7085..8b11d31 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -440,9 +440,18 @@ public: TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint); typeface = TypefaceImpl_resolveDefault(typeface); FakedFont baseFont = typeface->fFontCollection->baseFontFaked(typeface->fStyle); + float saveSkewX = paint->getTextSkewX(); + bool savefakeBold = paint->isFakeBoldText(); MinikinFontSkia::populateSkPaint(paint, baseFont.font, baseFont.fakery); #endif SkScalar spacing = paint->getFontMetrics(metrics); +#ifdef USE_MINIKIN + // The populateSkPaint call may have changed fake bold / text skew + // because we want to measure with those effects applied, so now + // restore the original settings. + paint->setTextSkewX(saveSkewX); + paint->setFakeBoldText(savefakeBold); +#endif SkPaintOptionsAndroid paintOpts = paint->getPaintOptionsAndroid(); if (paintOpts.getFontVariant() == SkPaintOptionsAndroid::kElegant_Variant) { SkScalar size = paint->getTextSize(); |