expose font-table APIs to SkTypeface
Review URL: https://codereview.appspot.com/6050046 git-svn-id: http://skia.googlecode.com/svn/trunk@3707 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
f3488ebaac
commit
f11508d7f4
@ -17,8 +17,6 @@ class SkDescriptor;
|
||||
class SkStream;
|
||||
class SkWStream;
|
||||
|
||||
typedef uint32_t SkFontTableTag;
|
||||
|
||||
/** \class SkFontHost
|
||||
|
||||
This class is ported to each environment. It is responsible for bridging
|
||||
|
@ -18,6 +18,7 @@ class SkAdvancedTypefaceMetrics;
|
||||
class SkWStream;
|
||||
|
||||
typedef uint32_t SkFontID;
|
||||
typedef uint32_t SkFontTableTag;
|
||||
|
||||
/** \class SkTypeface
|
||||
|
||||
@ -61,7 +62,7 @@ public:
|
||||
data. Will never return 0.
|
||||
*/
|
||||
SkFontID uniqueID() const { return fUniqueID; }
|
||||
|
||||
|
||||
/** Return the uniqueID for the specified typeface. If the face is null,
|
||||
resolve it to the default font and return its uniqueID. Will never
|
||||
return 0.
|
||||
@ -146,6 +147,46 @@ public:
|
||||
const uint32_t* glyphIDs = NULL,
|
||||
uint32_t glyphIDsCount = 0) const;
|
||||
|
||||
// Table getters -- may fail if the underlying font format is not organized
|
||||
// as 4-byte tables.
|
||||
|
||||
/** Return the number of tables in the font. */
|
||||
int countTables() const;
|
||||
|
||||
/** 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. If tags == NULL, this only returns the count
|
||||
* (the same as calling countTables()).
|
||||
*/
|
||||
int getTableTags(SkFontTableTag tags[]) const;
|
||||
|
||||
/** Given a table tag, return the size of its contents, or 0 if not present
|
||||
*/
|
||||
size_t getTableSize(SkFontTableTag) const;
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
size_t getTableData(SkFontTableTag tag, size_t offset, size_t length,
|
||||
void* data) const;
|
||||
|
||||
protected:
|
||||
/** uniqueID must be unique (please!) and non-zero
|
||||
*/
|
||||
|
@ -101,3 +101,23 @@ SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics(
|
||||
glyphIDs,
|
||||
glyphIDsCount);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int SkTypeface::countTables() const {
|
||||
return SkFontHost::CountTables(fUniqueID);
|
||||
}
|
||||
|
||||
int SkTypeface::getTableTags(SkFontTableTag tags[]) const {
|
||||
return SkFontHost::GetTableTags(fUniqueID, tags);
|
||||
}
|
||||
|
||||
size_t SkTypeface::getTableSize(SkFontTableTag tag) const {
|
||||
return SkFontHost::GetTableSize(fUniqueID, tag);
|
||||
}
|
||||
|
||||
size_t SkTypeface::getTableData(SkFontTableTag tag, size_t offset, size_t length,
|
||||
void* data) const {
|
||||
return SkFontHost::GetTableData(fUniqueID, tag, offset, length, data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user