diff options
-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(); |