'../src/ports/SkPurgeableMemoryBlock_none.cpp',
'../src/ports/SkThread_win.cpp',
- '../src/ports/SkFontHost_tables.cpp',
'../src/ports/SkMemory_malloc.cpp',
'../src/ports/SkOSFile_stdio.cpp',
'../src/ports/SkTime_Unix.cpp',
'../src/ports/SkFontConfigInterface_direct.cpp',
'../src/ports/SkThread_pthread.cpp',
],
- 'sources!': [
- '../src/ports/SkFontHost_tables.cpp',
- ],
}],
[ 'skia_os == "nacl"', {
'dependencies': [
const uint32_t* glyphIDs,
uint32_t glyphIDsCount);
- /** Return the number of tables in the font
- */
- static int CountTables(SkFontID);
-
- /** 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.
- */
- static int GetTableTags(SkFontID, SkFontTableTag[]);
-
- /** Given a table tag, return the size of its contents, or 0 if not present
- */
- static size_t GetTableSize(SkFontID, SkFontTableTag);
-
- /** 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.
- */
- static size_t GetTableData(SkFontID fontID, SkFontTableTag tag,
- size_t offset, size_t length, void* data);
-
///////////////////////////////////////////////////////////////////////////
friend class SkTypeface;
///////////////////////////////////////////////////////////////////////////////
int SkTypeface::countTables() const {
- return SkFontHost::CountTables(fUniqueID);
+ return this->onGetTableTags(NULL);
}
int SkTypeface::getTableTags(SkFontTableTag tags[]) const {
- return SkFontHost::GetTableTags(fUniqueID, tags);
+ return this->onGetTableTags(tags);
}
size_t SkTypeface::getTableSize(SkFontTableTag tag) const {
- return SkFontHost::GetTableSize(fUniqueID, tag);
+ return this->onGetTableData(tag, 0, ~0U, NULL);
}
size_t SkTypeface::getTableData(SkFontTableTag tag, size_t offset, size_t length,
void* data) const {
- return SkFontHost::GetTableData(fUniqueID, tag, offset, length, data);
+ return this->onGetTableData(tag, offset, length, data);
}
SkStream* SkTypeface::openStream(int* ttcIndex) const {
return SkFontHost::OpenStream(fUniqueID);
}
-int SkTypeface::onGetTableTags(SkFontTableTag tags[]) const { return 0; }
-size_t SkTypeface::onGetTableData(SkFontTableTag, size_t offset,
- size_t length, void* data) const { return 0; }
void SkTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const {
desc->setStyle(this->style());
}
+#include "SkFontStream.h"
+#include "SkStream.h"
+
+int SkTypeface::onGetTableTags(SkFontTableTag tags[]) const {
+ int ttcIndex;
+ SkAutoTUnref<SkStream> stream(this->openStream(&ttcIndex));
+ return stream.get() ? SkFontStream::GetTableTags(stream, ttcIndex, tags) : 0;
+}
+
+size_t SkTypeface::onGetTableData(SkFontTableTag tag, size_t offset,
+ size_t length, void* data) const {
+ int ttcIndex;
+ SkAutoTUnref<SkStream> stream(this->openStream(&ttcIndex));
+ return stream.get()
+ ? SkFontStream::GetTableData(stream, ttcIndex, tag, offset, length, data)
+ : 0;
+}
+
///////////////////////////////////////////////////////////////////////////////
-// DEPRECATED
-int SkFontHost::CountTables(SkFontID fontID) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableTags(NULL) : 0;
-}
-
-// DEPRECATED
-int SkFontHost::GetTableTags(SkFontID fontID, SkFontTableTag tags[]) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableTags(tags) : 0;
-}
-
-// DEPRECATED
-size_t SkFontHost::GetTableSize(SkFontID fontID, SkFontTableTag tag) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableData(tag, 0, ~0U, NULL) : 0;
-}
-
-// DEPRECATED
-size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
- size_t offset, size_t length, void* dst) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableData(tag, offset, length, dst) : 0;
-}
-
// DEPRECATED
SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID curr, SkFontID orig) {
// We don't handle font fallback.
desc->setStyle(this->style());
desc->setFamilyName(this->getFamilyName());
}
+
return SkSafeRef(face);
}
-// DEPRECATED
-int SkFontHost::CountTables(SkFontID fontID) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableTags(NULL) : 0;
-}
-
-// DEPRECATED
-int SkFontHost::GetTableTags(SkFontID fontID, SkFontTableTag tags[]) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableTags(tags) : 0;
-}
-
-// DEPRECATED
-size_t SkFontHost::GetTableSize(SkFontID fontID, SkFontTableTag tag) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableData(tag, 0, ~0U, NULL) : 0;
-}
-
-// DEPRECATED
-size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
- size_t offset, size_t length, void* dst) {
- SkTypeface* face = SkTypefaceCache::FindByID(fontID);
- return face ? face->onGetTableData(tag, offset, length, dst) : 0;
-}
-
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+++ /dev/null
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkEndian.h"
-#include "SkFontHost.h"
-#include "SkFontStream.h"
-#include "SkStream.h"
-
-int SkFontHost::CountTables(SkFontID fontID) {
- SkStream* stream = SkFontHost::OpenStream(fontID);
- if (NULL == stream) {
- return 0;
- }
-
- SkAutoUnref au(stream);
- int ttcIndex = 0;
- return SkFontStream::GetTableTags(stream, ttcIndex, NULL);
-}
-
-int SkFontHost::GetTableTags(SkFontID fontID, SkFontTableTag tags[]) {
- SkStream* stream = SkFontHost::OpenStream(fontID);
- if (NULL == stream) {
- return 0;
- }
-
- SkAutoUnref au(stream);
- int ttcIndex = 0;
- return SkFontStream::GetTableTags(stream, ttcIndex, tags);
-}
-
-size_t SkFontHost::GetTableSize(SkFontID fontID, SkFontTableTag tag) {
- SkStream* stream = SkFontHost::OpenStream(fontID);
- if (NULL == stream) {
- return 0;
- }
-
- SkAutoUnref au(stream);
- int ttcIndex = 0;
- return SkFontStream::GetTableData(stream, ttcIndex, tag, 0, ~0U, NULL);
-}
-
-size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
- size_t offset, size_t length, void* data) {
- SkStream* stream = SkFontHost::OpenStream(fontID);
- if (NULL == stream) {
- return 0;
- }
-
- SkAutoUnref au(stream);
- int ttcIndex = 0;
- return SkFontStream::GetTableData(stream, ttcIndex, tag, offset, length, data);
-}
HB_Error SkHarfBuzzFont::GetFontTableFunc(void* voidface, const HB_Tag tag,
HB_Byte* buffer, HB_UInt* len) {
SkHarfBuzzFont* font = reinterpret_cast<SkHarfBuzzFont*>(voidface);
- uint32_t uniqueID = SkTypeface::UniqueID(font->getTypeface());
+ SkTypeface* typeface = font->getTypeface();
- const size_t tableSize = SkFontHost::GetTableSize(uniqueID, tag);
+ const size_t tableSize = typeface->getTableSize(tag);
if (!tableSize) {
return HB_Err_Invalid_Argument;
}
// is this right, or should we just copy less than the full table?
return HB_Err_Invalid_Argument;
}
- SkFontHost::GetTableData(uniqueID, tag, 0, tableSize, buffer);
+ typeface->getTableData(tag, 0, tableSize, buffer);
return HB_Err_Ok;
}
+