SkFontStyleSet_DirectWrite::getStyle to properly handle NULL out params.

R=reed@google.com

Review URL: https://codereview.chromium.org/201213003

git-svn-id: http://skia.googlecode.com/svn/trunk@13829 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2014-03-17 14:04:50 +00:00
parent be4825c873
commit 1d1f2347d3

View File

@ -1832,27 +1832,31 @@ void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString*
SkTScopedComPtr<IDWriteFont> font; SkTScopedComPtr<IDWriteFont> font;
HRVM(fFontFamily->GetFont(index, &font), "Could not get font."); HRVM(fFontFamily->GetFont(index, &font), "Could not get font.");
SkFontStyle::Slant slant; if (fs) {
switch (font->GetStyle()) { SkFontStyle::Slant slant;
case DWRITE_FONT_STYLE_NORMAL: switch (font->GetStyle()) {
slant = SkFontStyle::kUpright_Slant; case DWRITE_FONT_STYLE_NORMAL:
break; slant = SkFontStyle::kUpright_Slant;
case DWRITE_FONT_STYLE_OBLIQUE: break;
case DWRITE_FONT_STYLE_ITALIC: case DWRITE_FONT_STYLE_OBLIQUE:
slant = SkFontStyle::kItalic_Slant; case DWRITE_FONT_STYLE_ITALIC:
break; slant = SkFontStyle::kItalic_Slant;
default: break;
SkASSERT(false); default:
SkASSERT(false);
}
int weight = font->GetWeight();
int width = font->GetStretch();
*fs = SkFontStyle(weight, width, slant);
} }
int weight = font->GetWeight(); if (styleName) {
int width = font->GetStretch(); SkTScopedComPtr<IDWriteLocalizedStrings> faceNames;
if (SUCCEEDED(font->GetFaceNames(&faceNames))) {
*fs = SkFontStyle(weight, width, slant); get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styleName);
}
SkTScopedComPtr<IDWriteLocalizedStrings> faceNames;
if (SUCCEEDED(font->GetFaceNames(&faceNames))) {
get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styleName);
} }
} }