Update windows port of of SkFontHost::GetAdvancedTypefaceMetrics to use calculateGlyphCount.

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

git-svn-id: http://skia.googlecode.com/svn/trunk@890 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
ctguil@chromium.org 2011-03-04 19:39:56 +00:00
parent eca7d34f1d
commit f7c2c4544f
2 changed files with 4 additions and 15 deletions

View File

@ -80,10 +80,7 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
int repeats = 0;
for (int gId = 0; gId < num_glyphs; gId++) {
Data advance;
if (!getAdvance(fontHandle, gId, &advance)) {
num_glyphs = (gId > 0) ? gId - 1 : 0;
break;
}
SkAssertResult(getAdvance(fontHandle, gId, &advance));
if (advance == lastAdvance) {
repeats++;
} else if (curRange->fAdvance.count() == repeats + 1) {

View File

@ -549,6 +549,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) {
goto Error;
}
const unsigned glyphCount = calculateGlyphCount(hdc);
info = new SkAdvancedTypefaceMetrics;
#ifdef UNICODE
@ -573,7 +574,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
}
info->fEmSize = otm.otmEMSquare;
info->fMultiMaster = false;
info->fLastGlyphID = 0;
info->fLastGlyphID = SkToU16(glyphCount - 1);
info->fStyle = 0;
// If this bit is clear the font is a fixed pitch font.
@ -627,16 +628,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
} else if (perGlyphInfo) {
info->fGlyphWidths.reset(
getAdvanceData(hdc, SHRT_MAX, &getWidthAdvance));
// Obtain the last glyph index.
SkAdvancedTypefaceMetrics::WidthRange* last = info->fGlyphWidths.get();
if (last) {
while (last->fNext.get()) {
last = last->fNext.get();
}
info->fLastGlyphID = last->fEndId;
}
getAdvanceData(hdc, glyphCount, &getWidthAdvance));
}
Error: