Improve generation of glyph advance array.

Review URL: http://codereview.appspot.com/4830068

git-svn-id: http://skia.googlecode.com/svn/trunk@2126 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
vandebo@chromium.org 2011-08-16 22:45:43 +00:00
parent 8b4a64d318
commit e7f3300f42
13 changed files with 198 additions and 93 deletions

View File

@ -132,10 +132,21 @@ void finishRange(
typename SkAdvancedTypefaceMetrics::AdvanceMetric<Data>::MetricType typename SkAdvancedTypefaceMetrics::AdvanceMetric<Data>::MetricType
type); type);
/** Retrieve advance data for glyphs. Used by the PDF backend. It calls
underlying platform dependent API getAdvance to acquire the data.
@param num_glyphs Total number of glyphs in the given font.
@param glyphIDs For per-glyph info, specify subset of the font by
giving glyph ids. Each integer represents a glyph
id. Passing NULL means all glyphs in the font.
@param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if
glyphIDs is NULL.
*/
template <typename Data, typename FontHandle> template <typename Data, typename FontHandle>
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData( SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
FontHandle fontHandle, FontHandle fontHandle,
int num_glyphs, int num_glyphs,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount,
bool (*getAdvance)(FontHandle fontHandle, int gId, Data* data)); bool (*getAdvance)(FontHandle fontHandle, int gId, Data* data));
} // namespace skia_advanced_typeface_metrics_utils } // namespace skia_advanced_typeface_metrics_utils

View File

@ -181,10 +181,17 @@ public:
names, etc.) should be populated. names, etc.) should be populated.
@return The returned object has already been referenced. NULL is @return The returned object has already been referenced. NULL is
returned if the font is not found. returned if the font is not found.
@param glyphIDs For per-glyph info, specify subset of the font by
giving glyph ids. Each integer represents a glyph
id. Passing NULL means all glyphs in the font.
@param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if
glyphIDs is NULL.
*/ */
static SkAdvancedTypefaceMetrics* GetAdvancedTypefaceMetrics( static SkAdvancedTypefaceMetrics* GetAdvancedTypefaceMetrics(
SkFontID fontID, SkFontID fontID,
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo); SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount);
/** Return the number of tables in the font /** Return the number of tables in the font
*/ */
@ -293,4 +300,3 @@ public:
}; };
#endif #endif

View File

@ -134,10 +134,17 @@ public:
/** Retrieve detailed typeface metrics. Used by the PDF backend. /** Retrieve detailed typeface metrics. Used by the PDF backend.
@param perGlyphInfo Indicate what glyph specific information (advances, @param perGlyphInfo Indicate what glyph specific information (advances,
names, etc.) should be populated. names, etc.) should be populated.
@param glyphIDs For per-glyph info, specify subset of the font by
giving glyph ids. Each integer represents a glyph
id. Passing NULL means all glyphs in the font.
@param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if
glyphIDs is NULL.
@return The returned object has already been referenced. @return The returned object has already been referenced.
*/ */
SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics( SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) const; SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs = NULL,
uint32_t glyphIDsCount = 0) const;
protected: protected:
/** uniqueID must be unique (please!) and non-zero /** uniqueID must be unique (please!) and non-zero

View File

@ -478,4 +478,3 @@ private:
#endif /* C++ */ #endif /* C++ */
#endif #endif

View File

@ -137,6 +137,7 @@ protected:
// Accessors for subclass. // Accessors for subclass.
SkAdvancedTypefaceMetrics* fontInfo(); SkAdvancedTypefaceMetrics* fontInfo();
void setFontInfo(SkAdvancedTypefaceMetrics* info);
uint16_t firstGlyphID() const; uint16_t firstGlyphID() const;
uint16_t lastGlyphID() const; uint16_t lastGlyphID() const;
void setLastGlyphID(uint16_t glyphID); void setLastGlyphID(uint16_t glyphID);

View File

@ -65,6 +65,8 @@ template <typename Data, typename FontHandle>
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData( SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
FontHandle fontHandle, FontHandle fontHandle,
int num_glyphs, int num_glyphs,
const uint32_t* subsetGlyphIDs,
uint32_t subsetGlyphIDsLength,
bool (*getAdvance)(FontHandle fontHandle, int gId, Data* data)) { bool (*getAdvance)(FontHandle fontHandle, int gId, Data* data)) {
// Assuming that an ASCII representation of a width or a glyph id is, // Assuming that an ASCII representation of a width or a glyph id is,
// on average, 3 characters long gives the following cut offs for // on average, 3 characters long gives the following cut offs for
@ -82,10 +84,17 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
curRange = appendRange(&result, 0); curRange = appendRange(&result, 0);
Data lastAdvance = SK_MinS16; Data lastAdvance = SK_MinS16;
int repeats = 0; int repeats = 0;
uint32_t subsetIndex = 0;
for (int gId = 0; gId <= num_glyphs; gId++) { for (int gId = 0; gId <= num_glyphs; gId++) {
Data advance; Data advance = 0;
if (gId < num_glyphs) { if (gId < num_glyphs) {
// Get glyph id only when subset is NULL, or the id is in subset.
if (!subsetGlyphIDs ||
(subsetIndex < subsetGlyphIDsLength &&
static_cast<uint32_t>(gId) == subsetGlyphIDs[subsetIndex])) {
SkAssertResult(getAdvance(fontHandle, gId, &advance)); SkAssertResult(getAdvance(fontHandle, gId, &advance));
++subsetIndex;
}
} else { } else {
advance = SK_MinS16; advance = SK_MinS16;
} }
@ -139,16 +148,22 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData(
HDC hdc, HDC hdc,
int num_glyphs, int num_glyphs,
const uint32_t* subsetGlyphIDs,
uint32_t subsetGlyphIDsLength,
bool (*getAdvance)(HDC hdc, int gId, int16_t* data)); bool (*getAdvance)(HDC hdc, int gId, int16_t* data));
#elif defined(SK_BUILD_FOR_UNIX) #elif defined(SK_BUILD_FOR_UNIX)
template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData(
FT_Face face, FT_Face face,
int num_glyphs, int num_glyphs,
const uint32_t* subsetGlyphIDs,
uint32_t subsetGlyphIDsLength,
bool (*getAdvance)(FT_Face face, int gId, int16_t* data)); bool (*getAdvance)(FT_Face face, int gId, int16_t* data));
#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData(
CTFontRef ctFont, CTFontRef ctFont,
int num_glyphs, int num_glyphs,
const uint32_t* subsetGlyphIDs,
uint32_t subsetGlyphIDsLength,
bool (*getAdvance)(CTFontRef ctFont, int gId, int16_t* data)); bool (*getAdvance)(CTFontRef ctFont, int gId, int16_t* data));
#endif #endif
template void resetRange( template void resetRange(

View File

@ -93,6 +93,11 @@ SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
} }
SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) const { SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
return SkFontHost::GetAdvancedTypefaceMetrics(fUniqueID, perGlyphInfo); const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
return SkFontHost::GetAdvancedTypefaceMetrics(fUniqueID,
perGlyphInfo,
glyphIDs,
glyphIDsCount);
} }

View File

@ -528,7 +528,7 @@ static void sk_delete_array(const void* ptr, size_t, void*) {
static int get_subset_font_stream(const char* fontName, static int get_subset_font_stream(const char* fontName,
const SkTypeface* typeface, const SkTypeface* typeface,
const SkPDFGlyphSet* subset, const SkTDArray<uint32_t>& subset,
SkPDFStream** fontStream) { SkPDFStream** fontStream) {
SkRefPtr<SkStream> fontData = SkRefPtr<SkStream> fontData =
SkFontHost::OpenStream(SkTypeface::UniqueID(typeface)); SkFontHost::OpenStream(SkTypeface::UniqueID(typeface));
@ -537,11 +537,6 @@ static int get_subset_font_stream(const char* fontName,
int fontSize = fontData->getLength(); int fontSize = fontData->getLength();
#if defined (SK_SFNTLY_SUBSETTER) #if defined (SK_SFNTLY_SUBSETTER)
// Generate glyph id array.
SkTDArray<uint32_t> glyphIDs;
glyphIDs.push(0); // Always include glyph 0.
subset->exportTo(&glyphIDs);
// Read font into buffer. // Read font into buffer.
SkPDFStream* subsetFontStream = NULL; SkPDFStream* subsetFontStream = NULL;
SkTDArray<unsigned char> originalFont; SkTDArray<unsigned char> originalFont;
@ -555,8 +550,8 @@ static int get_subset_font_stream(const char* fontName,
int subsetFontSize = SfntlyWrapper::SubsetFont(fontName, int subsetFontSize = SfntlyWrapper::SubsetFont(fontName,
originalFont.begin(), originalFont.begin(),
fontSize, fontSize,
glyphIDs.begin(), subset.begin(),
glyphIDs.count(), subset.count(),
&subsetFont); &subsetFont);
if (subsetFontSize > 0 && subsetFont != NULL) { if (subsetFontSize > 0 && subsetFont != NULL) {
SkAutoDataUnref data(SkData::NewWithProc(subsetFont, SkAutoDataUnref data(SkData::NewWithProc(subsetFont,
@ -751,13 +746,26 @@ SkPDFFont* SkPDFFont::GetFontResource(SkTypeface* typeface, uint16_t glyphID) {
relatedFontDescriptor = relatedFont->getFontDescriptor(); relatedFontDescriptor = relatedFont->getFontDescriptor();
} else { } else {
SkAdvancedTypefaceMetrics::PerGlyphInfo info; SkAdvancedTypefaceMetrics::PerGlyphInfo info;
info = SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo; info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo;
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo);
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo); info, SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo);
fontMetrics = SkFontHost::GetAdvancedTypefaceMetrics(fontID, info); #if !defined (SK_SFNTLY_SUBSETTER)
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo);
#endif
fontMetrics =
SkFontHost::GetAdvancedTypefaceMetrics(fontID, info, NULL, 0);
#if defined (SK_SFNTLY_SUBSETTER)
SkSafeUnref(fontMetrics.get()); // SkRefPtr and Get both took a ref. SkSafeUnref(fontMetrics.get()); // SkRefPtr and Get both took a ref.
if (fontMetrics->fType != SkAdvancedTypefaceMetrics::kTrueType_Font) {
// Font does not support subsetting, get new info with advance.
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo);
fontMetrics =
SkFontHost::GetAdvancedTypefaceMetrics(fontID, info, NULL, 0);
SkSafeUnref(fontMetrics.get()); // SkRefPtr and Get both took a ref
}
#endif
} }
SkPDFFont* font = Create(fontMetrics.get(), typeface, glyphID, SkPDFFont* font = Create(fontMetrics.get(), typeface, glyphID,
@ -850,6 +858,13 @@ SkAdvancedTypefaceMetrics* SkPDFFont::fontInfo() {
return fFontInfo.get(); return fFontInfo.get();
} }
void SkPDFFont::setFontInfo(SkAdvancedTypefaceMetrics* info) {
if (info == NULL || info == fFontInfo.get()) {
return;
}
fFontInfo = info;
}
uint16_t SkPDFFont::firstGlyphID() const { uint16_t SkPDFFont::firstGlyphID() const {
return fFirstGlyphID; return fFirstGlyphID;
} }
@ -978,9 +993,10 @@ bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) {
insertName("BaseFont", fontInfo()->fFontName); insertName("BaseFont", fontInfo()->fFontName);
insertName("Encoding", "Identity-H"); insertName("Encoding", "Identity-H");
SkPDFCIDFont* newCIDFont;
newCIDFont = new SkPDFCIDFont(fontInfo(), typeface(), subset);
// Pass ref new created to fResources. // Pass ref new created to fResources.
SkPDFCIDFont* newCIDFont =
new SkPDFCIDFont(fontInfo(), typeface(), subset);
addResource(newCIDFont); addResource(newCIDFont);
SkRefPtr<SkPDFArray> descendantFonts = new SkPDFArray(); SkRefPtr<SkPDFArray> descendantFonts = new SkPDFArray();
descendantFonts->unref(); // SkRefPtr and new took a reference. descendantFonts->unref(); // SkRefPtr and new took a reference.
@ -1006,18 +1022,19 @@ SkPDFCIDFont::SkPDFCIDFont(SkAdvancedTypefaceMetrics* info,
SkPDFCIDFont::~SkPDFCIDFont() {} SkPDFCIDFont::~SkPDFCIDFont() {}
bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
const SkPDFGlyphSet* subset) { const SkTDArray<uint32_t>* subset) {
SkRefPtr<SkPDFDict> descriptor = new SkPDFDict("FontDescriptor"); SkRefPtr<SkPDFDict> descriptor = new SkPDFDict("FontDescriptor");
descriptor->unref(); // SkRefPtr and new both took a ref. descriptor->unref(); // SkRefPtr and new both took a ref.
setFontDescriptor(descriptor.get()); setFontDescriptor(descriptor.get());
switch (getType()) { switch (getType()) {
case SkAdvancedTypefaceMetrics::kTrueType_Font: { case SkAdvancedTypefaceMetrics::kTrueType_Font: {
SkASSERT(subset);
// Font subsetting // Font subsetting
SkPDFStream* rawStream = NULL; SkPDFStream* rawStream = NULL;
int fontSize = get_subset_font_stream(fontInfo()->fFontName.c_str(), int fontSize = get_subset_font_stream(fontInfo()->fFontName.c_str(),
typeface(), typeface(),
subset, *subset,
&rawStream); &rawStream);
SkASSERT(fontSize); SkASSERT(fontSize);
SkASSERT(rawStream); SkASSERT(rawStream);
@ -1060,6 +1077,35 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
} }
bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
// Generate new font metrics with advance info for true type fonts.
if (fontInfo()->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) {
// Generate glyph id array.
SkTDArray<uint32_t> glyphIDs;
glyphIDs.push(0); // Always include glyph 0.
if (subset) {
subset->exportTo(&glyphIDs);
}
SkRefPtr<SkAdvancedTypefaceMetrics> fontMetrics;
SkAdvancedTypefaceMetrics::PerGlyphInfo info;
info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo;
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo);
uint32_t* glyphs = (glyphIDs.count() == 1) ? NULL : glyphIDs.begin();
uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0;
fontMetrics =
SkFontHost::GetAdvancedTypefaceMetrics(typeface()->uniqueID(),
info,
glyphs,
glyphsCount);
SkSafeUnref(fontMetrics.get()); // SkRefPtr and Get both took a ref
setFontInfo(fontMetrics.get());
addFontDescriptor(0, &glyphIDs);
} else {
// Other CID fonts
addFontDescriptor(0, NULL);
}
insertName("BaseFont", fontInfo()->fFontName); insertName("BaseFont", fontInfo()->fFontName);
if (getType() == SkAdvancedTypefaceMetrics::kType1CID_Font) { if (getType() == SkAdvancedTypefaceMetrics::kType1CID_Font) {
@ -1078,8 +1124,6 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
sysInfo->insertInt("Supplement", 0); sysInfo->insertInt("Supplement", 0);
insert("CIDSystemInfo", sysInfo.get()); insert("CIDSystemInfo", sysInfo.get());
addFontDescriptor(0, subset);
if (fontInfo()->fGlyphWidths.get()) { if (fontInfo()->fGlyphWidths.get()) {
int16_t defaultWidth = 0; int16_t defaultWidth = 0;
SkRefPtr<SkPDFArray> widths = SkRefPtr<SkPDFArray> widths =

View File

@ -46,7 +46,8 @@ private:
const SkPDFGlyphSet* subset); const SkPDFGlyphSet* subset);
bool populate(const SkPDFGlyphSet* subset); bool populate(const SkPDFGlyphSet* subset);
bool addFontDescriptor(int16_t defaultWidth, const SkPDFGlyphSet* subset); bool addFontDescriptor(int16_t defaultWidth,
const SkTDArray<uint32_t>* subset);
}; };
class SkPDFType1Font : public SkPDFFont { class SkPDFType1Font : public SkPDFFont {

View File

@ -408,7 +408,9 @@ static void populate_glyph_to_unicode(FT_Face& face,
// static // static
SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
uint32_t fontID, uint32_t fontID,
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) { SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) {
#if defined(SK_BUILD_FOR_MAC) || defined(ANDROID) #if defined(SK_BUILD_FOR_MAC) || defined(ANDROID)
return NULL; return NULL;
#else #else
@ -552,7 +554,11 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::WidthRange::kRange); SkAdvancedTypefaceMetrics::WidthRange::kRange);
} else { } else {
info->fGlyphWidths.reset( info->fGlyphWidths.reset(
getAdvanceData(face, face->num_glyphs, &getWidthAdvance)); getAdvanceData(face,
face->num_glyphs,
glyphIDs,
glyphIDsCount,
&getWidthAdvance));
} }
} }
@ -588,6 +594,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
return info; return info;
#endif #endif
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static bool bothZero(SkScalar a, SkScalar b) { static bool bothZero(SkScalar a, SkScalar b) {

View File

@ -476,7 +476,9 @@ SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
// static // static
SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
uint32_t fontID, uint32_t fontID,
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) { SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) {
SkASSERT(!"SkFontHost::GetAdvancedTypefaceMetrics unimplemented"); SkASSERT(!"SkFontHost::GetAdvancedTypefaceMetrics unimplemented");
return NULL; return NULL;
} }
@ -609,4 +611,3 @@ size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
} }
return length; return length;
} }

View File

@ -761,7 +761,9 @@ static bool getWidthAdvance(CTFontRef ctFont, int gId, int16_t* data) {
// static // static
SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
uint32_t fontID, uint32_t fontID,
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) { SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) {
CTFontRef ctFont = GetFontRefFromFontID(fontID); CTFontRef ctFont = GetFontRefFromFontID(fontID);
ctFont = CTFontCreateCopyWithAttributes(ctFont, CTFontGetUnitsPerEm(ctFont), ctFont = CTFontCreateCopyWithAttributes(ctFont, CTFontGetUnitsPerEm(ctFont),
NULL, NULL); NULL, NULL);
@ -847,7 +849,11 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::WidthRange::kDefault); SkAdvancedTypefaceMetrics::WidthRange::kDefault);
} else { } else {
info->fGlyphWidths.reset( info->fGlyphWidths.reset(
getAdvanceData(ctFont, glyphCount, &getWidthAdvance)); getAdvanceData(ctFont,
glyphCount,
glyphIDs,
glyphIDsCount,
&getWidthAdvance));
} }
} }
@ -1115,7 +1121,3 @@ size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
memcpy(data, CFDataGetBytePtr(cfData) + offset, length); memcpy(data, CFDataGetBytePtr(cfData) + offset, length);
return(length); return(length);
} }

View File

@ -743,7 +743,9 @@ static bool getWidthAdvance(HDC hdc, int gId, int16_t* advance) {
// static // static
SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
uint32_t fontID, uint32_t fontID,
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) { SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) {
LOGFONT lf; LOGFONT lf;
GetLogFontByID(fontID, &lf); GetLogFontByID(fontID, &lf);
SkAdvancedTypefaceMetrics* info = NULL; SkAdvancedTypefaceMetrics* info = NULL;
@ -863,7 +865,11 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::WidthRange::kDefault); SkAdvancedTypefaceMetrics::WidthRange::kDefault);
} else { } else {
info->fGlyphWidths.reset( info->fGlyphWidths.reset(
getAdvanceData(hdc, glyphCount, &getWidthAdvance)); getAdvanceData(hdc,
glyphCount,
glyphIDs,
glyphIDsCount,
&getWidthAdvance));
} }
} }