diff options
author | Victoria Lease <violets@google.com> | 2012-06-13 10:23:10 -0700 |
---|---|---|
committer | Victoria Lease <violets@google.com> | 2012-06-13 16:42:34 -0700 |
commit | ec1ad08b13b4034af0ae2e65da7803250a7eece3 (patch) | |
tree | 6f22710ccae80d084c50d4d9727925481006931f /src | |
parent | bd64a4dd0d45eb7ea09dd46e2e5f3291655dbc5e (diff) | |
download | external_skia-ec1ad08b13b4034af0ae2e65da7803250a7eece3.zip external_skia-ec1ad08b13b4034af0ae2e65da7803250a7eece3.tar.gz external_skia-ec1ad08b13b4034af0ae2e65da7803250a7eece3.tar.bz2 |
DO NOT MERGE Skia solution to fake-bold fallback fonts.
This version of the fake-bold-for-fallback-fonts fix addresses the
issue succinctly inside of Skia, with no need for Skia's clients to
be aware of the issue. Attempts to draw a bold parent font flag the
embolden flag in the associated SkScalerContext while leaving the
SkPaint's fake bold flag unmodified.
This depends upon change Icdd13f6b, which arranges for FreeType's
FontHost to ignore redundant embolden requests.
This is a cherry-pick of change I4132a232 from master.
Bug: 6629786
Change-Id: I389d6793e5472d664f6ac7b894927dbfd811be12
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPaint.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 07fe9b0..e1932a7 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1447,7 +1447,8 @@ void SkScalerContext::MakeRec(const SkPaint& paint, const SkMatrix* deviceMatrix, Rec* rec) { SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); - rec->fOrigFontID = SkTypeface::UniqueID(paint.getTypeface()); + SkTypeface* typeface = paint.getTypeface(); + rec->fOrigFontID = SkTypeface::UniqueID(typeface); rec->fFontID = rec->fOrigFontID; rec->fTextSize = paint.getTextSize(); rec->fPreScaleX = paint.getTextScaleX(); @@ -1468,10 +1469,21 @@ void SkScalerContext::MakeRec(const SkPaint& paint, unsigned flags = 0; - if (paint.isFakeBoldText()) { #ifdef SK_USE_FREETYPE_EMBOLDEN + // It is possible that the SkTypeface used to draw glyphs has + // different properties than the SkTypeface set in the SkPaint. + // If we are asked to render bold text with a bold font, and are + // forced to fall back to a font with normal weight for some + // glyphs, we need to use fake bold to render those glyphs. In + // order to do that, we set SkScalerContext's "embolden" flag + // here if we are trying to draw bold text via any means, and + // ignore it at the glyph outline generation stage if the font + // actually being used is already bold. + if (paint.isFakeBoldText() || (typeface && typeface->isBold())) { flags |= SkScalerContext::kEmbolden_Flag; + } #else + if (paint.isFakeBoldText()) { SkScalar fakeBoldScale = SkScalarInterpFunc(paint.getTextSize(), kStdFakeBoldInterpKeys, kStdFakeBoldInterpValues, @@ -1484,8 +1496,8 @@ void SkScalerContext::MakeRec(const SkPaint& paint, } else { strokeWidth += extra; } -#endif } +#endif if (paint.isDevKernText()) { flags |= SkScalerContext::kDevKernText_Flag; |