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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 const uint32_t*, uint32_t) const SK_OVERRIDE; | 567 const uint32_t*, uint32_t) const SK_OVERRIDE; |
568 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; | 568 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; |
569 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, | 569 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, |
570 uint16_t glyphs[], int glyphCount) const SK_OVER
RIDE; | 570 uint16_t glyphs[], int glyphCount) const SK_OVER
RIDE; |
571 virtual int onCountGlyphs() const SK_OVERRIDE; | 571 virtual int onCountGlyphs() const SK_OVERRIDE; |
572 virtual int onGetUPEM() const SK_OVERRIDE; | 572 virtual int onGetUPEM() const SK_OVERRIDE; |
573 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; | 573 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; |
574 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 574 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
575 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 575 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
576 size_t length, void* data) const SK_OVERRIDE; | 576 size_t length, void* data) const SK_OVERRIDE; |
577 virtual SkTypeface* onRefMatchingStyle(Style) const SK_OVERRIDE; | |
578 }; | 577 }; |
579 | 578 |
580 class SkScalerContext_DW : public SkScalerContext { | 579 class SkScalerContext_DW : public SkScalerContext { |
581 public: | 580 public: |
582 SkScalerContext_DW(DWriteFontTypeface*, const SkDescriptor* desc); | 581 SkScalerContext_DW(DWriteFontTypeface*, const SkDescriptor* desc); |
583 virtual ~SkScalerContext_DW(); | 582 virtual ~SkScalerContext_DW(); |
584 | 583 |
585 protected: | 584 protected: |
586 virtual unsigned generateGlyphCount() SK_OVERRIDE; | 585 virtual unsigned generateGlyphCount() SK_OVERRIDE; |
587 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; | 586 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 ? DWRITE_FONT_STYLE_ITALIC | 1754 ? DWRITE_FONT_STYLE_ITALIC |
1756 : DWRITE_FONT_STYLE_NORMAL; | 1755 : DWRITE_FONT_STYLE_NORMAL; |
1757 hr = fontFamily->GetFirstMatchingFont(weight, stretch, italic, &font); | 1756 hr = fontFamily->GetFirstMatchingFont(weight, stretch, italic, &font); |
1758 | 1757 |
1759 SkTScopedComPtr<IDWriteFontFace> fontFace; | 1758 SkTScopedComPtr<IDWriteFontFace> fontFace; |
1760 hr = font->CreateFontFace(&fontFace); | 1759 hr = font->CreateFontFace(&fontFace); |
1761 | 1760 |
1762 return fontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fon
tFamily.get()); | 1761 return fontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fon
tFamily.get()); |
1763 } | 1762 } |
1764 | 1763 |
1765 SkTypeface* DWriteFontTypeface::onRefMatchingStyle(Style style) const { | |
1766 SkFontMgr_DirectWrite* fontMgr = NULL; | |
1767 // todo: should each typeface have a ref to its fontmgr/cache? | |
1768 return create_typeface(this, NULL, style, fontMgr); | |
1769 } | |
1770 | |
1771 /////////////////////////////////////////////////////////////////////////////// | 1764 /////////////////////////////////////////////////////////////////////////////// |
1772 | 1765 |
1773 static void get_locale_string(IDWriteLocalizedStrings* names, const WCHAR* prefe
redLocale, | 1766 static void get_locale_string(IDWriteLocalizedStrings* names, const WCHAR* prefe
redLocale, |
1774 SkString* skname) { | 1767 SkString* skname) { |
1775 UINT32 nameIndex = 0; | 1768 UINT32 nameIndex = 0; |
1776 if (preferedLocale) { | 1769 if (preferedLocale) { |
1777 // Ignore any errors and continue with index 0 if there is a problem. | 1770 // Ignore any errors and continue with index 0 if there is a problem. |
1778 BOOL nameExists; | 1771 BOOL nameExists; |
1779 names->FindLocaleName(preferedLocale, &nameIndex, &nameExists); | 1772 names->FindLocaleName(preferedLocale, &nameIndex, &nameExists); |
1780 if (!nameExists) { | 1773 if (!nameExists) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 | 1939 |
1947 SkTScopedComPtr<IDWriteFontFace> fontFace; | 1940 SkTScopedComPtr<IDWriteFontFace> fontFace; |
1948 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); | 1941 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); |
1949 | 1942 |
1950 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), | 1943 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), |
1951 fFontFamily.get()); | 1944 fFontFamily.get()); |
1952 } | 1945 } |
1953 | 1946 |
1954 /////////////////////////////////////////////////////////////////////////////// | 1947 /////////////////////////////////////////////////////////////////////////////// |
1955 | 1948 |
1956 #ifndef SK_FONTHOST_USES_FONTMGR | |
1957 | |
1958 SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, | |
1959 const char familyName[], | |
1960 SkTypeface::Style style) { | |
1961 return create_typeface(familyFace, familyName, style, NULL); | |
1962 } | |
1963 | |
1964 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { | |
1965 printf("SkFontHost::CreateTypefaceFromFile unimplemented"); | |
1966 return NULL; | |
1967 } | |
1968 | |
1969 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { | |
1970 return create_from_stream(stream, 0); | |
1971 } | |
1972 | |
1973 #endif | |
1974 | |
1975 typedef decltype(GetUserDefaultLocaleName)* GetUserDefaultLocaleNameProc; | 1949 typedef decltype(GetUserDefaultLocaleName)* GetUserDefaultLocaleNameProc; |
1976 static HRESULT GetGetUserDefaultLocaleNameProc(GetUserDefaultLocaleNameProc* pro
c) { | 1950 static HRESULT GetGetUserDefaultLocaleNameProc(GetUserDefaultLocaleNameProc* pro
c) { |
1977 *proc = reinterpret_cast<GetUserDefaultLocaleNameProc>( | 1951 *proc = reinterpret_cast<GetUserDefaultLocaleNameProc>( |
1978 GetProcAddress(LoadLibraryW(L"Kernel32.dll"), "GetUserDefaultLocaleName"
) | 1952 GetProcAddress(LoadLibraryW(L"Kernel32.dll"), "GetUserDefaultLocaleName"
) |
1979 ); | 1953 ); |
1980 if (!*proc) { | 1954 if (!*proc) { |
1981 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); | 1955 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); |
1982 if (!IS_ERROR(hr)) { | 1956 if (!IS_ERROR(hr)) { |
1983 hr = ERROR_PROC_NOT_FOUND; | 1957 hr = ERROR_PROC_NOT_FOUND; |
1984 } | 1958 } |
(...skipping 21 matching lines...) Expand all Loading... |
2006 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1980 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
2007 } else { | 1981 } else { |
2008 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1982 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
2009 if (localeNameLen) { | 1983 if (localeNameLen) { |
2010 localeName = localeNameStorage; | 1984 localeName = localeNameStorage; |
2011 }; | 1985 }; |
2012 } | 1986 } |
2013 | 1987 |
2014 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); | 1988 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); |
2015 } | 1989 } |
OLD | NEW |