Index: src/ports/SkFontHost_FreeType.cpp |
=================================================================== |
--- src/ports/SkFontHost_FreeType.cpp (revision 10497) |
+++ src/ports/SkFontHost_FreeType.cpp (working copy) |
@@ -203,8 +203,6 @@ |
/////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////// |
-#include "SkStream.h" |
- |
struct SkFaceRec { |
SkFaceRec* fNext; |
FT_Face fFace; |
@@ -1404,6 +1402,62 @@ |
return fGlyphCount; |
} |
+int SkTypeface_FreeType::onGetTableTags(SkFontTableTag tags[]) const { |
+ AutoFTAccess fta(this); |
+ FT_Face face = fta.face(); |
+ |
+ FT_ULong tableCount = 0; |
+ FT_Error error; |
+ |
+ // When 'tag' is NULL, returns number of tables in 'length'. |
+ error = FT_Sfnt_Table_Info(face, 0, NULL, &tableCount); |
+ if (error) { |
+ return 0; |
+ } |
+ |
+ if (tags) { |
+ for (FT_ULong tableIndex = 0; tableIndex < tableCount; ++tableIndex) { |
+ FT_ULong tableTag; |
+ FT_ULong tablelength; |
+ error = FT_Sfnt_Table_Info(face, tableIndex, &tableTag, &tablelength); |
+ if (error) { |
+ return 0; |
+ } |
+ tags[tableIndex] = static_cast<SkFontTableTag>(tableTag); |
+ } |
+ } |
+ return tableCount; |
+} |
+ |
+size_t SkTypeface_FreeType::onGetTableData(SkFontTableTag tag, size_t offset, |
+ size_t length, void* data) const |
+{ |
+ AutoFTAccess fta(this); |
+ FT_Face face = fta.face(); |
+ |
+ FT_ULong tableLength = 0; |
+ FT_Error error; |
+ |
+ // When 'length' is 0 it is overwritten with the full table length; 'offset' is ignored. |
+ error = FT_Load_Sfnt_Table(face, tag, 0, NULL, &tableLength); |
+ if (error) { |
+ return 0; |
+ } |
+ |
+ if (offset > tableLength) { |
+ return 0; |
+ } |
+ FT_ULong size = SkTMin(length, tableLength - offset); |
+ if (NULL != data) { |
+ error = FT_Load_Sfnt_Table(face, tag, offset, reinterpret_cast<FT_Byte*>(data), &size); |
+ if (error) { |
+ return 0; |
+ } |
+ } |
+ |
+ return size; |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////////// |