aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBilly Hewlett <billyh@google.com>2012-06-04 13:37:11 -0700
committerBilly Hewlett <billyh@google.com>2012-06-04 17:14:06 -0700
commitcde7dcc5111806870f94721561056e990a9211c8 (patch)
tree243dcaea32ace3df1174302a91b7d5924bd09039 /include
parent287b065688229e4750fd3fbabbf50c3a36ae87e5 (diff)
downloadexternal_skia-cde7dcc5111806870f94721561056e990a9211c8.zip
external_skia-cde7dcc5111806870f94721561056e990a9211c8.tar.gz
external_skia-cde7dcc5111806870f94721561056e990a9211c8.tar.bz2
Fix hardcoded font path. Allow adding new font path thru Skia changes.
Bug: 6609231 Change-Id: Ie37ada42e7e78ab78318f3ed76eb627bffaddb1a
Diffstat (limited to 'include')
-rw-r--r--include/core/SkScalerContext.h14
-rw-r--r--include/ports/SkTypeface_android.h56
2 files changed, 70 insertions, 0 deletions
diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h
index 29679d6..9bcf601 100644
--- a/include/core/SkScalerContext.h
+++ b/include/core/SkScalerContext.h
@@ -15,6 +15,7 @@
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPoint.h"
+#include "SkTypeface.h"
//#define SK_USE_COLOR_LUMINANCE
@@ -299,6 +300,19 @@ public:
SkPaint::FontMetrics* mY);
#ifdef SK_BUILD_FOR_ANDROID
+ // This function must be public for SkTypeface_android.h, but should not be
+ // called by other callers
+ SkFontID findTypefaceIdForChar(SkUnichar uni) {
+ SkScalerContext* ctx = this;
+ while (NULL != ctx) {
+ if (ctx->generateCharToGlyph(uni)) {
+ return ctx->fRec.fFontID;
+ }
+ ctx = ctx->getNextContext();
+ }
+ return 0;
+ }
+
unsigned getBaseGlyphCount(SkUnichar charCode);
#endif
diff --git a/include/ports/SkTypeface_android.h b/include/ports/SkTypeface_android.h
new file mode 100644
index 0000000..3471a94
--- /dev/null
+++ b/include/ports/SkTypeface_android.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#ifndef SkTypeface_android_DEFINED
+#define SkTypeface_android_DEFINED
+
+#include "SkTypeface.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)
+
+/**
+ * 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.
+ */
+SK_API FallbackScripts SkGetFallbackScriptFromID(const char* id);
+
+#endif