diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-17 14:04:50 +0000 |
---|---|---|
committer | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-17 14:04:50 +0000 |
commit | 1d1f2347d303852172fb7629c27d295ef68d9a3c (patch) | |
tree | 0d59b3a476e13b9cd1b4eea280755b6e36616514 /src/ports | |
parent | be4825c873856d8a6a91ea19cf1499da4b0a1fc1 (diff) |
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
Diffstat (limited to 'src/ports')
-rw-r--r-- | src/ports/SkFontHost_win_dw.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp index b80154aa61..39b83e9d1a 100644 --- a/src/ports/SkFontHost_win_dw.cpp +++ b/src/ports/SkFontHost_win_dw.cpp @@ -1832,27 +1832,31 @@ void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString* SkTScopedComPtr<IDWriteFont> font; HRVM(fFontFamily->GetFont(index, &font), "Could not get font."); - SkFontStyle::Slant slant; - switch (font->GetStyle()) { - case DWRITE_FONT_STYLE_NORMAL: - slant = SkFontStyle::kUpright_Slant; - break; - case DWRITE_FONT_STYLE_OBLIQUE: - case DWRITE_FONT_STYLE_ITALIC: - slant = SkFontStyle::kItalic_Slant; - break; - default: - SkASSERT(false); - } + if (fs) { + SkFontStyle::Slant slant; + switch (font->GetStyle()) { + case DWRITE_FONT_STYLE_NORMAL: + slant = SkFontStyle::kUpright_Slant; + break; + case DWRITE_FONT_STYLE_OBLIQUE: + case DWRITE_FONT_STYLE_ITALIC: + slant = SkFontStyle::kItalic_Slant; + break; + default: + SkASSERT(false); + } - int weight = font->GetWeight(); - int width = font->GetStretch(); + int weight = font->GetWeight(); + int width = font->GetStretch(); - *fs = SkFontStyle(weight, width, slant); + *fs = SkFontStyle(weight, width, slant); + } - SkTScopedComPtr<IDWriteLocalizedStrings> faceNames; - if (SUCCEEDED(font->GetFaceNames(&faceNames))) { - get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styleName); + if (styleName) { + SkTScopedComPtr<IDWriteLocalizedStrings> faceNames; + if (SUCCEEDED(font->GetFaceNames(&faceNames))) { + get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styleName); + } } } |