diff options
author | Mike Reed <reed@google.com> | 2009-06-17 10:37:49 -0400 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2009-06-17 10:37:49 -0400 |
commit | b91f67b5c82b6d5f399a629b1434fc40a271737c (patch) | |
tree | c15170c89f986bbcd6d481e89d1cf3b05826dc5e /WebKit/android | |
parent | 1a17067aadae754be7c580797459e3f41e398b45 (diff) | |
download | external_webkit-b91f67b5c82b6d5f399a629b1434fc40a271737c.zip external_webkit-b91f67b5c82b6d5f399a629b1434fc40a271737c.tar.gz external_webkit-b91f67b5c82b6d5f399a629b1434fc40a271737c.tar.bz2 |
add font table getters for plugins
Diffstat (limited to 'WebKit/android')
-rw-r--r-- | WebKit/android/plugins/ANPTypefaceInterface.cpp | 27 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 39 |
2 files changed, 66 insertions, 0 deletions
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 @@ static ANPTypefaceStyle anp_getStyle(const ANPTypeface* tf) { 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 @@ void ANPTypefaceInterfaceV0_Init(ANPInterface* v) { 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 @@ enum ANPTypefaceStyles { }; 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 @@ struct ANPTypefaceInterfaceV0 : ANPInterface { /** 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 { |