aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorBilly Hewlett <billyh@google.com>2012-06-11 15:52:55 -0700
committerBilly Hewlett <billyh@google.com>2012-06-20 17:43:50 -0700
commit421654d4bf3ca50e2247a7389851d2e8f4812564 (patch)
tree5b6eb6755286f93262832dfa701b53594c89ef84 /src/core
parent926a65a184e682ec054aa5f6f4fa4a46b3847c24 (diff)
downloadexternal_skia-421654d4bf3ca50e2247a7389851d2e8f4812564.zip
external_skia-421654d4bf3ca50e2247a7389851d2e8f4812564.tar.gz
external_skia-421654d4bf3ca50e2247a7389851d2e8f4812564.tar.bz2
Use Elegant fonts for Webkit, Compact fonts for Textview
Fonts can be marked with elegant or compact in fallback_fonts.xml. Webkit uses elegant fonts, Textview uses compact fonts (the default), unmarked fonts are used by both. Bug: 6649136 Change-Id: I6ab6173c2efc50eba8fcc488c89dfdd083fb9c06
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPaint.cpp16
-rw-r--r--src/core/SkScalerContext.cpp8
2 files changed, 23 insertions, 1 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index e1932a7..412ab2b 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -72,6 +72,7 @@ SkPaint::SkPaint() {
fHinting = SkPaintDefaults_Hinting;
#ifdef SK_BUILD_FOR_ANDROID
new(&fTextLocale) SkString();
+ fFontVariant = kDefault_Variant;
fGenerationID = 0;
#endif
}
@@ -372,6 +373,18 @@ void SkPaint::setTextLocale(const SkString& locale) {
GEN_ID_INC;
}
}
+
+void SkPaint::setFontVariant(FontVariant fontVariant) {
+ if ((unsigned)fontVariant <= kLast_Variant) {
+ GEN_ID_INC_EVAL((unsigned)fontVariant != fFontVariant);
+ fFontVariant = fontVariant;
+ } else {
+#ifdef SK_REPORT_API_RANGE_CHECK
+ SkDebugf("SkPaint::setFontVariant(%d) out of range\n", fontVariant);
+#endif
+ }
+}
+
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -1561,6 +1574,9 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
#else
rec->setLuminanceBits(computeLuminance(paint));
#endif
+#ifdef SK_BUILD_FOR_ANDROID
+ rec->fFontVariant = paint.getFontVariant();
+#endif //SK_BUILD_FOR_ANDROID
/* Allow the fonthost to modify our rec before we use it as a key into the
cache. This way if we're asking for something that they will ignore,
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 2921b1e..e33ad7a 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -118,7 +118,13 @@ static SkScalerContext* allocNextContext(const SkScalerContext::Rec& rec) {
// fonthost will determine the next possible font to search, based
// on the current font in fRec. It will return NULL if ctx is our
// last font that can be searched (i.e. ultimate fallback font)
- uint32_t newFontID = SkFontHost::NextLogicalFont(rec.fFontID, rec.fOrigFontID);
+#ifdef SK_BUILD_FOR_ANDROID
+ // On Android, pass entire rec structure so that clients can change fallback behavior
+ uint32_t newFontID = SkFontHost::NextLogicalFont(rec);
+#else
+ uint32_t newFontID = SkFontHost::NextLogicalFont(rec.fFontID, rec.fOrigFontID);
+#endif
+
if (0 == newFontID) {
return NULL;
}