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:
parent
eca7d34f1d
commit
f7c2c4544f
@ -80,10 +80,7 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
|
|||||||
int repeats = 0;
|
int repeats = 0;
|
||||||
for (int gId = 0; gId < num_glyphs; gId++) {
|
for (int gId = 0; gId < num_glyphs; gId++) {
|
||||||
Data advance;
|
Data advance;
|
||||||
if (!getAdvance(fontHandle, gId, &advance)) {
|
SkAssertResult(getAdvance(fontHandle, gId, &advance));
|
||||||
num_glyphs = (gId > 0) ? gId - 1 : 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (advance == lastAdvance) {
|
if (advance == lastAdvance) {
|
||||||
repeats++;
|
repeats++;
|
||||||
} else if (curRange->fAdvance.count() == repeats + 1) {
|
} else if (curRange->fAdvance.count() == repeats + 1) {
|
||||||
|
@ -549,6 +549,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
|
|||||||
if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) {
|
if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) {
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
const unsigned glyphCount = calculateGlyphCount(hdc);
|
||||||
|
|
||||||
info = new SkAdvancedTypefaceMetrics;
|
info = new SkAdvancedTypefaceMetrics;
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
@ -573,7 +574,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
|
|||||||
}
|
}
|
||||||
info->fEmSize = otm.otmEMSquare;
|
info->fEmSize = otm.otmEMSquare;
|
||||||
info->fMultiMaster = false;
|
info->fMultiMaster = false;
|
||||||
info->fLastGlyphID = 0;
|
info->fLastGlyphID = SkToU16(glyphCount - 1);
|
||||||
|
|
||||||
info->fStyle = 0;
|
info->fStyle = 0;
|
||||||
// If this bit is clear the font is a fixed pitch font.
|
// If this bit is clear the font is a fixed pitch font.
|
||||||
@ -627,16 +628,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
|
|||||||
info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
|
info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
|
||||||
} else if (perGlyphInfo) {
|
} else if (perGlyphInfo) {
|
||||||
info->fGlyphWidths.reset(
|
info->fGlyphWidths.reset(
|
||||||
getAdvanceData(hdc, SHRT_MAX, &getWidthAdvance));
|
getAdvanceData(hdc, glyphCount, &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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Error:
|
Error:
|
||||||
|
Loading…
Reference in New Issue
Block a user