diff options
author | Mike Reed <reed@google.com> | 2009-07-17 15:53:27 -0400 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2009-07-17 15:53:27 -0400 |
commit | ae107e96f52ebe258a8ef5f32100c77ededc2d34 (patch) | |
tree | 2f08595ed7b6f8230f9736dfd79e055bc5665217 | |
parent | f86737b0ce8c81f2b529503f83eb8b064769eeca (diff) | |
download | external_webkit-ae107e96f52ebe258a8ef5f32100c77ededc2d34.zip external_webkit-ae107e96f52ebe258a8ef5f32100c77ededc2d34.tar.gz external_webkit-ae107e96f52ebe258a8ef5f32100c77ededc2d34.tar.bz2 |
add fontdir api for plugins
remove unneeded fonttable apis
-rw-r--r-- | WebKit/android/plugins/ANPTypefaceInterface.cpp | 42 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 39 |
2 files changed, 22 insertions, 59 deletions
diff --git a/WebKit/android/plugins/ANPTypefaceInterface.cpp b/WebKit/android/plugins/ANPTypefaceInterface.cpp index f4823d6..d560d3e 100644 --- a/WebKit/android/plugins/ANPTypefaceInterface.cpp +++ b/WebKit/android/plugins/ANPTypefaceInterface.cpp @@ -58,26 +58,25 @@ 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 const char* gFontDir; +#define FONT_DIR_SUFFIX "/fonts/" -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); +static const char* anp_getFontDirectoryPath() { + if (NULL == gFontDir) { + const char* root = getenv("ANDROID_ROOT"); + size_t len = strlen(root); + char* storage = (char*)malloc(len + sizeof(FONT_DIR_SUFFIX)); + if (NULL == storage) { + return NULL; + } + memcpy(storage, root, len); + memcpy(storage + len, FONT_DIR_SUFFIX, sizeof(FONT_DIR_SUFFIX)); + // save this assignment for last, so that if multiple threads call us + // (which should never happen), we never return an incomplete global. + // At worst, we would allocate storage for the path twice. + gFontDir = storage; + } + return gFontDir; } /////////////////////////////////////////////////////////////////////////////// @@ -93,9 +92,6 @@ 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); + ASSIGN(i, getFontDirectoryPath); } diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 7f01024..41c1080 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -464,42 +464,9 @@ struct ANPTypefaceInterfaceV0 : ANPInterface { */ 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); + /** Return the path name for the font directory, or NULL if not supported + */ + const char* (*getFontDirectoryPath)(); }; struct ANPPaintInterfaceV0 : ANPInterface { |