Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: src/ports/SkFontHost_win_dw.cpp

Issue 214843002: Add a default-default font for DirectWrite. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 } 1667 }
1668 1668
1669 HRESULT SkFontMgr_DirectWrite::getByFamilyName(const WCHAR wideFamilyName[], 1669 HRESULT SkFontMgr_DirectWrite::getByFamilyName(const WCHAR wideFamilyName[],
1670 IDWriteFontFamily** fontFamily) c onst { 1670 IDWriteFontFamily** fontFamily) c onst {
1671 UINT32 index; 1671 UINT32 index;
1672 BOOL exists; 1672 BOOL exists;
1673 HR(fFontCollection->FindFamilyName(wideFamilyName, &index, &exists)); 1673 HR(fFontCollection->FindFamilyName(wideFamilyName, &index, &exists));
1674 1674
1675 if (exists) { 1675 if (exists) {
1676 HR(fFontCollection->GetFontFamily(index, fontFamily)); 1676 HR(fFontCollection->GetFontFamily(index, fontFamily));
1677 return S_OK;
1678 } 1677 }
1679 return S_FALSE; 1678 return S_OK;
1680 } 1679 }
1681 1680
1682 HRESULT SkFontMgr_DirectWrite::getDefaultFontFamily(IDWriteFontFamily** fontFami ly) const { 1681 HRESULT SkFontMgr_DirectWrite::getDefaultFontFamily(IDWriteFontFamily** fontFami ly) const {
1683 NONCLIENTMETRICSW metrics; 1682 NONCLIENTMETRICSW metrics;
1684 metrics.cbSize = sizeof(metrics); 1683 metrics.cbSize = sizeof(metrics);
1685 if (0 == SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 1684 if (0 == SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
1686 sizeof(metrics), 1685 sizeof(metrics),
1687 &metrics, 1686 &metrics,
1688 0)) { 1687 0)) {
1689 return E_UNEXPECTED; 1688 return E_UNEXPECTED;
1690 } 1689 }
1691 HRM(this->getByFamilyName(metrics.lfMessageFont.lfFaceName, fontFamily), 1690 HRM(this->getByFamilyName(metrics.lfMessageFont.lfFaceName, fontFamily),
1692 "Could not create DWrite font family from LOGFONT."); 1691 "Could not create DWrite font family from LOGFONT.");
1693
1694 return S_OK; 1692 return S_OK;
1695 } 1693 }
1696 1694
1697 SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[ ], 1695 SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[ ],
1698 unsigned styleBits) co nst { 1696 unsigned styleBits) co nst {
1699 SkTScopedComPtr<IDWriteFontFamily> fontFamily; 1697 SkTScopedComPtr<IDWriteFontFamily> fontFamily;
1700 if (familyName) { 1698 if (familyName) {
1701 SkSMallocWCHAR wideFamilyName; 1699 SkSMallocWCHAR wideFamilyName;
1702 if (SUCCEEDED(sk_cstring_to_wchar(familyName, &wideFamilyName))) { 1700 if (SUCCEEDED(sk_cstring_to_wchar(familyName, &wideFamilyName))) {
1703 this->getByFamilyName(wideFamilyName, &fontFamily); 1701 this->getByFamilyName(wideFamilyName, &fontFamily);
1704 } 1702 }
1705 } 1703 }
1706 1704
1707 if (NULL == fontFamily.get()) { 1705 if (NULL == fontFamily.get()) {
1708 // No family with given name, try default. 1706 // No family with given name, try default.
1709 HRNM(this->getDefaultFontFamily(&fontFamily), "Could not get default fon t family."); 1707 HRNM(this->getDefaultFontFamily(&fontFamily), "Could not get default fon t family.");
1710 } 1708 }
1711 1709
1710 if (NULL == fontFamily.get()) {
1711 // Could not obtain the default font.
1712 HRNM(fFontCollection->GetFontFamily(0, &fontFamily),
1713 "Could not get default-default font family.");
1714 }
1715
1712 SkTScopedComPtr<IDWriteFont> font; 1716 SkTScopedComPtr<IDWriteFont> font;
1713 DWRITE_FONT_WEIGHT weight = (styleBits & SkTypeface::kBold) 1717 DWRITE_FONT_WEIGHT weight = (styleBits & SkTypeface::kBold)
1714 ? DWRITE_FONT_WEIGHT_BOLD 1718 ? DWRITE_FONT_WEIGHT_BOLD
1715 : DWRITE_FONT_WEIGHT_NORMAL; 1719 : DWRITE_FONT_WEIGHT_NORMAL;
1716 DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH_NORMAL; 1720 DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH_NORMAL;
1717 DWRITE_FONT_STYLE italic = (styleBits & SkTypeface::kItalic) 1721 DWRITE_FONT_STYLE italic = (styleBits & SkTypeface::kItalic)
1718 ? DWRITE_FONT_STYLE_ITALIC 1722 ? DWRITE_FONT_STYLE_ITALIC
1719 : DWRITE_FONT_STYLE_NORMAL; 1723 : DWRITE_FONT_STYLE_NORMAL;
1720 HRNM(fontFamily->GetFirstMatchingFont(weight, stretch, italic, &font), 1724 HRNM(fontFamily->GetFirstMatchingFont(weight, stretch, italic, &font),
1721 "Could not get matching font."); 1725 "Could not get matching font.");
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 } 1838 }
1835 1839
1836 #include "SkFontMgr_indirect.h" 1840 #include "SkFontMgr_indirect.h"
1837 SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { 1841 SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) {
1838 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); 1842 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite());
1839 if (impl.get() == NULL) { 1843 if (impl.get() == NULL) {
1840 return NULL; 1844 return NULL;
1841 } 1845 }
1842 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); 1846 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy));
1843 } 1847 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698