add font table getters for plugins
diff --git a/WebKit/android/plugins/ANPTypefaceInterface.cpp b/WebKit/android/plugins/ANPTypefaceInterface.cpp
index 17b3067..f4823d6 100644
--- a/WebKit/android/plugins/ANPTypefaceInterface.cpp
+++ b/WebKit/android/plugins/ANPTypefaceInterface.cpp
@@ -26,6 +26,7 @@
// must include config.h first for webkit to fiddle with new/delete
#include "config.h"
#include "SkANP.h"
+#include "SkFontHost.h"
static ANPTypeface* anp_createFromName(const char name[], ANPTypefaceStyle s) {
SkTypeface* tf = SkTypeface::CreateFromName(name,
@@ -57,6 +58,28 @@
return static_cast<ANPTypefaceStyle>(s);
}
+static uint32_t anp_countTables(const ANPTypeface* tf) {
+ SkFontID id = SkTypeface::UniqueID(tf);
+ return SkFontHost::CountTables(id);
+}
+
+static uint32_t anp_getTableTags(const ANPTypeface* tf,
+ ANPFontTableTag tags[]) {
+ SkFontID id = SkTypeface::UniqueID(tf);
+ return SkFontHost::GetTableTags(id, tags);
+}
+
+static uint32_t anp_getTableSize(const ANPTypeface* tf, ANPFontTableTag tag) {
+ SkFontID id = SkTypeface::UniqueID(tf);
+ return SkFontHost::GetTableSize(id, tag);
+}
+
+static uint32_t anp_getTableData(const ANPTypeface* tf, ANPFontTableTag tag,
+ uint32_t offset, uint32_t length, void* data) {
+ SkFontID id = SkTypeface::UniqueID(tf);
+ return SkFontHost::GetTableData(id, tag, offset, length, data);
+}
+
///////////////////////////////////////////////////////////////////////////////
#define ASSIGN(obj, name) (obj)->name = anp_##name
@@ -70,5 +93,9 @@
ASSIGN(i, ref);
ASSIGN(i, unref);
ASSIGN(i, getStyle);
+ ASSIGN(i, countTables);
+ ASSIGN(i, getTableTags);
+ ASSIGN(i, getTableSize);
+ ASSIGN(i, getTableData);
}
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index bda8eeb..596d2ac 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -347,6 +347,8 @@
};
typedef uint32_t ANPTypefaceStyle;
+typedef uint32_t ANPFontTableTag;
+
struct ANPFontMetrics {
//! The greatest distance above the baseline for any glyph (will be <= 0)
float fTop;
@@ -403,6 +405,43 @@
/** Return the style bits for the specified typeface
*/
ANPTypefaceStyle (*getStyle)(const ANPTypeface*);
+
+ /** Return the number of tables in the font
+ */
+ uint32_t (*countTables)(const ANPTypeface*);
+
+ /** Copy into tags[] (allocated by the caller) the list of table tags in
+ the font, and return the number. This will be the same as CountTables()
+ or 0 if an error occured.
+ */
+ uint32_t (*getTableTags)(const ANPTypeface*, ANPFontTableTag tags[]);
+
+ /** Given a table tag, return the size of its contents, or 0 if not present
+ */
+ uint32_t (*getTableSize)(const ANPTypeface*, ANPFontTableTag);
+
+ /** Copy the contents of a table into data (allocated by the caller). Note
+ that the contents of the table will be in their native endian order
+ (which for most truetype tables is big endian). If the table tag is
+ not found, or there is an error copying the data, then 0 is returned.
+ If this happens, it is possible that some or all of the memory pointed
+ to by data may have been written to, even though an error has occured.
+
+ @param fontID the font to copy the table from
+ @param tag The table tag whose contents are to be copied
+ @param offset The offset in bytes into the table's contents where the
+ copy should start from.
+ @param length The number of bytes, starting at offset, of table data
+ to copy.
+ @param data storage address where the table contents are copied to
+ @return the number of bytes actually copied into data. If offset+length
+ exceeds the table's size, then only the bytes up to the table's
+ size are actually copied, and this is the value returned. If
+ offset > the table's size, or tag is not a valid table,
+ then 0 is returned.
+ */
+ uint32_t (*getTableData)(const ANPTypeface*, ANPFontTableTag,
+ uint32_t offset, uint32_t length, void* data);
};
struct ANPPaintInterfaceV0 : ANPInterface {