aboutsummaryrefslogtreecommitdiffstats
path: root/include
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 /include
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 'include')
-rw-r--r--include/core/SkFontHost.h9
-rw-r--r--include/core/SkPaint.h20
-rw-r--r--include/core/SkScalerContext.h4
-rw-r--r--include/ports/SkTypeface_android.h45
4 files changed, 41 insertions, 37 deletions
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h
index 25c9ecb..ace08d8 100644
--- a/include/core/SkFontHost.h
+++ b/include/core/SkFontHost.h
@@ -154,6 +154,15 @@ public:
*/
static SkFontID NextLogicalFont(SkFontID currFontID, SkFontID origFontID);
+#ifdef SK_BUILD_FOR_ANDROID
+ /*
+ * This Android-only version of NextLogicalFont allows us to pass in an
+ * entire Rec structure so that a caller can change fallback behavior
+ */
+ static SkFontID NextLogicalFont(const SkScalerContext::Rec& rec);
+#endif
+
+
///////////////////////////////////////////////////////////////////////////
/** Given a filled-out rec, the fonthost may decide to modify it to reflect
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index 30ff663..1715013 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -665,6 +665,25 @@ public:
@param locale set the paint's locale value for drawing text.
*/
void setTextLocale(const SkString& locale);
+
+
+ enum FontVariant {
+ kDefault_Variant, // Currently setting yourself to Default gives you Compact Variant
+ kCompact_Variant,
+ kElegant_Variant,
+ kLast_Variant = kElegant_Variant,
+ };
+
+ /** Return the font variant
+ @return the font variant used by this paint object
+ */
+ FontVariant getFontVariant() const { return fFontVariant; }
+
+
+ /** Set the font variant
+ @param fontVariant set the paint's font variant for choosing fonts
+ */
+ void setFontVariant(FontVariant fontVariant);
#endif
/** Return the paint's text size.
@@ -906,6 +925,7 @@ private:
unsigned fHinting : 2;
#ifdef SK_BUILD_FOR_ANDROID
SkString fTextLocale;
+ FontVariant fFontVariant;
#endif
SkDrawCacheProc getDrawCacheProc() const;
diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h
index 9bcf601..33c3c3d 100644
--- a/include/core/SkScalerContext.h
+++ b/include/core/SkScalerContext.h
@@ -210,6 +210,9 @@ public:
#ifdef SK_USE_COLOR_LUMINANCE
uint32_t fLumBits;
#endif
+#ifdef SK_BUILD_FOR_ANDROID
+ SkPaint::FontVariant fFontVariant;
+#endif
uint8_t fMaskFormat;
uint8_t fStrokeJoin;
uint16_t fFlags;
@@ -234,7 +237,6 @@ public:
SkMask::Format getFormat() const {
return static_cast<SkMask::Format>(fMaskFormat);
}
-
#ifdef SK_USE_COLOR_LUMINANCE
SkColor getLuminanceColor() const {
return fLumBits;
diff --git a/include/ports/SkTypeface_android.h b/include/ports/SkTypeface_android.h
index 3471a94..c3eb3d1 100644
--- a/include/ports/SkTypeface_android.h
+++ b/include/ports/SkTypeface_android.h
@@ -10,47 +10,20 @@
#define SkTypeface_android_DEFINED
#include "SkTypeface.h"
+#include "SkPaint.h"
-enum FallbackScripts {
- kArabic_FallbackScript,
- kArmenian_FallbackScript,
- kBengali_FallbackScript,
- kDevanagari_FallbackScript,
- kEthiopic_FallbackScript,
- kGeorgian_FallbackScript,
- kHebrewRegular_FallbackScript,
- kHebrewBold_FallbackScript,
- kKannada_FallbackScript,
- kMalayalam_FallbackScript,
- kTamilRegular_FallbackScript,
- kTamilBold_FallbackScript,
- kThai_FallbackScript,
- kTelugu_FallbackScript,
- kFallbackScriptNumber
-};
-
-#define SkTypeface_ValidScript(s) (s >= 0 && s < kFallbackScriptNumber)
+#include "../harfbuzz/src/harfbuzz-shaper.h"
/**
* Return a new typeface for a fallback script. If the script is
* not valid, or can not map to a font, returns null.
- * @param script The script id.
- * @return reference to the matching typeface. Caller must call
- * unref() when they are done.
- */
-SK_API SkTypeface* SkCreateTypefaceForScript(FallbackScripts script);
-
-/**
- * Return the string representation for the fallback script on Android.
- * If the script is not valid, returns null.
- */
-SK_API const char* SkGetFallbackScriptID(FallbackScripts script);
-
-/**
- * Return the fallback script enum for the ID on Android.
- * If the ID is not valid, or can not map to a fallback
- * script, returns kFallbackScriptNumber.
+ * @param script The harfbuzz script id.
+ * @param style The font style, for example bold
+ * @param elegant true if we want the web friendly elegant version of the font
+ * @return reference to the matching typeface. Caller must call
+ * unref() when they are done.
*/
-SK_API FallbackScripts SkGetFallbackScriptFromID(const char* id);
+SK_API SkTypeface* SkCreateTypefaceForScript(HB_Script script, SkTypeface::Style style,
+ SkPaint::FontVariant fontVariant = SkPaint::kDefault_Variant);
#endif