summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-08-03 06:39:58 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-08-03 06:39:58 -0700
commit8c161d7a8b485a2dc06347dfb6c8771904c4afda (patch)
tree3da3595d7e75aa498aa6c16faa7f62c0bc61a737 /WebKit
parent51c0d4c6b1b74fff7336d81451ba7d2fc132e31c (diff)
parent3cec237b4a0df2776318c343c9ccc9bbbcfd11f8 (diff)
downloadexternal_webkit-8c161d7a8b485a2dc06347dfb6c8771904c4afda.zip
external_webkit-8c161d7a8b485a2dc06347dfb6c8771904c4afda.tar.gz
external_webkit-8c161d7a8b485a2dc06347dfb6c8771904c4afda.tar.bz2
Merge change 9343
* changes: expose getFontPath to plugins
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/plugins/ANPTypefaceInterface.cpp8
-rw-r--r--WebKit/android/plugins/android_npapi.h29
2 files changed, 37 insertions, 0 deletions
diff --git a/WebKit/android/plugins/ANPTypefaceInterface.cpp b/WebKit/android/plugins/ANPTypefaceInterface.cpp
index d560d3e..e33e580 100644
--- a/WebKit/android/plugins/ANPTypefaceInterface.cpp
+++ b/WebKit/android/plugins/ANPTypefaceInterface.cpp
@@ -58,6 +58,13 @@ static ANPTypefaceStyle anp_getStyle(const ANPTypeface* tf) {
return static_cast<ANPTypefaceStyle>(s);
}
+static int32_t anp_getFontPath(const ANPTypeface* tf, char fileName[],
+ int32_t length, int32_t* index) {
+ size_t size = SkFontHost::GetFileName(SkTypeface::UniqueID(tf), fileName,
+ length, index);
+ return static_cast<int32_t>(size);
+}
+
static const char* gFontDir;
#define FONT_DIR_SUFFIX "/fonts/"
@@ -92,6 +99,7 @@ void ANPTypefaceInterfaceV0_Init(ANPInterface* v) {
ASSIGN(i, ref);
ASSIGN(i, unref);
ASSIGN(i, getStyle);
+ ASSIGN(i, getFontPath);
ASSIGN(i, getFontDirectoryPath);
}
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index e50f031..80fd2c4 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -463,6 +463,35 @@ struct ANPTypefaceInterfaceV0 : ANPInterface {
*/
ANPTypefaceStyle (*getStyle)(const ANPTypeface*);
+ /** Some fonts are stored in files. If that is true for the fontID, then
+ this returns the byte length of the full file path. If path is not null,
+ then the full path is copied into path (allocated by the caller), up to
+ length bytes. If index is not null, then it is set to the truetype
+ collection index for this font, or 0 if the font is not in a collection.
+
+ Note: getFontPath does not assume that path is a null-terminated string,
+ so when it succeeds, it only copies the bytes of the file name and
+ nothing else (i.e. it copies exactly the number of bytes returned by the
+ function. If the caller wants to treat path[] as a C string, it must be
+ sure that it is allocated at least 1 byte larger than the returned size,
+ and it must copy in the terminating 0.
+
+ If the fontID does not correspond to a file, then the function returns
+ 0, and the path and index parameters are ignored.
+
+ @param fontID The font whose file name is being queried
+ @param path Either NULL, or storage for receiving up to length bytes
+ of the font's file name. Allocated by the caller.
+ @param length The maximum space allocated in path (by the caller).
+ Ignored if path is NULL.
+ @param index Either NULL, or receives the TTC index for this font.
+ If the font is not a TTC, then will be set to 0.
+ @return The byte length of th font's file name, or 0 if the font is not
+ baked by a file.
+ */
+ int32_t (*getFontPath)(const ANPTypeface*, char path[], int32_t length,
+ int32_t* index);
+
/** Return the path name for the font directory, or NULL if not supported
*/
const char* (*getFontDirectoryPath)();