OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
9 #undef GetGlyphIndices | 9 #undef GetGlyphIndices |
10 | 10 |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 SkTScopedComPtr<IDWriteFontFace> fontFace; | 1825 SkTScopedComPtr<IDWriteFontFace> fontFace; |
1826 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); | 1826 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); |
1827 | 1827 |
1828 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fF
ontFamily.get()); | 1828 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fF
ontFamily.get()); |
1829 } | 1829 } |
1830 | 1830 |
1831 void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString*
styleName) { | 1831 void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString*
styleName) { |
1832 SkTScopedComPtr<IDWriteFont> font; | 1832 SkTScopedComPtr<IDWriteFont> font; |
1833 HRVM(fFontFamily->GetFont(index, &font), "Could not get font."); | 1833 HRVM(fFontFamily->GetFont(index, &font), "Could not get font."); |
1834 | 1834 |
1835 SkFontStyle::Slant slant; | 1835 if (fs) { |
1836 switch (font->GetStyle()) { | 1836 SkFontStyle::Slant slant; |
1837 case DWRITE_FONT_STYLE_NORMAL: | 1837 switch (font->GetStyle()) { |
1838 slant = SkFontStyle::kUpright_Slant; | 1838 case DWRITE_FONT_STYLE_NORMAL: |
1839 break; | 1839 slant = SkFontStyle::kUpright_Slant; |
1840 case DWRITE_FONT_STYLE_OBLIQUE: | 1840 break; |
1841 case DWRITE_FONT_STYLE_ITALIC: | 1841 case DWRITE_FONT_STYLE_OBLIQUE: |
1842 slant = SkFontStyle::kItalic_Slant; | 1842 case DWRITE_FONT_STYLE_ITALIC: |
1843 break; | 1843 slant = SkFontStyle::kItalic_Slant; |
1844 default: | 1844 break; |
1845 SkASSERT(false); | 1845 default: |
| 1846 SkASSERT(false); |
| 1847 } |
| 1848 |
| 1849 int weight = font->GetWeight(); |
| 1850 int width = font->GetStretch(); |
| 1851 |
| 1852 *fs = SkFontStyle(weight, width, slant); |
1846 } | 1853 } |
1847 | 1854 |
1848 int weight = font->GetWeight(); | 1855 if (styleName) { |
1849 int width = font->GetStretch(); | 1856 SkTScopedComPtr<IDWriteLocalizedStrings> faceNames; |
1850 | 1857 if (SUCCEEDED(font->GetFaceNames(&faceNames))) { |
1851 *fs = SkFontStyle(weight, width, slant); | 1858 get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styl
eName); |
1852 | 1859 } |
1853 SkTScopedComPtr<IDWriteLocalizedStrings> faceNames; | |
1854 if (SUCCEEDED(font->GetFaceNames(&faceNames))) { | |
1855 get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styleNam
e); | |
1856 } | 1860 } |
1857 } | 1861 } |
1858 | 1862 |
1859 SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) { | 1863 SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) { |
1860 DWRITE_FONT_STYLE slant; | 1864 DWRITE_FONT_STYLE slant; |
1861 switch (pattern.slant()) { | 1865 switch (pattern.slant()) { |
1862 case SkFontStyle::kUpright_Slant: | 1866 case SkFontStyle::kUpright_Slant: |
1863 slant = DWRITE_FONT_STYLE_NORMAL; | 1867 slant = DWRITE_FONT_STYLE_NORMAL; |
1864 break; | 1868 break; |
1865 case SkFontStyle::kItalic_Slant: | 1869 case SkFontStyle::kItalic_Slant: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1926 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
1923 } else { | 1927 } else { |
1924 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1928 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
1925 if (localeNameLen) { | 1929 if (localeNameLen) { |
1926 localeName = localeNameStorage; | 1930 localeName = localeNameStorage; |
1927 }; | 1931 }; |
1928 } | 1932 } |
1929 | 1933 |
1930 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); | 1934 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); |
1931 } | 1935 } |
OLD | NEW |