OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef SkTypeface_win_dw_DEFINED | 8 #ifndef SkTypeface_win_dw_DEFINED |
9 #define SkTypeface_win_dw_DEFINED | 9 #define SkTypeface_win_dw_DEFINED |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 case DWRITE_FONT_STYLE_NORMAL: slant = SkFontStyle::kUpright_Slant; brea
k; | 32 case DWRITE_FONT_STYLE_NORMAL: slant = SkFontStyle::kUpright_Slant; brea
k; |
33 case DWRITE_FONT_STYLE_OBLIQUE: slant = SkFontStyle::kOblique_Slant; bre
ak; | 33 case DWRITE_FONT_STYLE_OBLIQUE: slant = SkFontStyle::kOblique_Slant; bre
ak; |
34 case DWRITE_FONT_STYLE_ITALIC: slant = SkFontStyle::kItalic_Slant; break
; | 34 case DWRITE_FONT_STYLE_ITALIC: slant = SkFontStyle::kItalic_Slant; break
; |
35 default: SkASSERT(false); break; | 35 default: SkASSERT(false); break; |
36 } | 36 } |
37 return SkFontStyle(weight, width, slant); | 37 return SkFontStyle(weight, width, slant); |
38 } | 38 } |
39 | 39 |
40 class DWriteFontTypeface : public SkTypeface { | 40 class DWriteFontTypeface : public SkTypeface { |
41 private: | 41 private: |
42 DWriteFontTypeface(const SkFontStyle& style, SkFontID fontID, | 42 DWriteFontTypeface(const SkFontStyle& style, |
43 IDWriteFactory* factory, | 43 IDWriteFactory* factory, |
44 IDWriteFontFace* fontFace, | 44 IDWriteFontFace* fontFace, |
45 IDWriteFont* font, | 45 IDWriteFont* font, |
46 IDWriteFontFamily* fontFamily, | 46 IDWriteFontFamily* fontFamily, |
47 IDWriteFontFileLoader* fontFileLoader = nullptr, | 47 IDWriteFontFileLoader* fontFileLoader = nullptr, |
48 IDWriteFontCollectionLoader* fontCollectionLoader = nullp
tr) | 48 IDWriteFontCollectionLoader* fontCollectionLoader = nullp
tr) |
49 : SkTypeface(style, fontID, false) | 49 : SkTypeface(style, false) |
50 , fFactory(SkRefComPtr(factory)) | 50 , fFactory(SkRefComPtr(factory)) |
51 , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader)) | 51 , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader)) |
52 , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader)) | 52 , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader)) |
53 , fDWriteFontFamily(SkRefComPtr(fontFamily)) | 53 , fDWriteFontFamily(SkRefComPtr(fontFamily)) |
54 , fDWriteFont(SkRefComPtr(font)) | 54 , fDWriteFont(SkRefComPtr(font)) |
55 , fDWriteFontFace(SkRefComPtr(fontFace)) | 55 , fDWriteFontFace(SkRefComPtr(fontFace)) |
56 { | 56 { |
57 #if SK_HAS_DWRITE_1_H | 57 #if SK_HAS_DWRITE_1_H |
58 if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) { | 58 if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) { |
59 // IUnknown::QueryInterface states that if it fails, punk will be se
t to nullptr. | 59 // IUnknown::QueryInterface states that if it fails, punk will be se
t to nullptr. |
(...skipping 13 matching lines...) Expand all Loading... |
73 #if SK_HAS_DWRITE_1_H | 73 #if SK_HAS_DWRITE_1_H |
74 SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1; | 74 SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1; |
75 #endif | 75 #endif |
76 | 76 |
77 static DWriteFontTypeface* Create(IDWriteFactory* factory, | 77 static DWriteFontTypeface* Create(IDWriteFactory* factory, |
78 IDWriteFontFace* fontFace, | 78 IDWriteFontFace* fontFace, |
79 IDWriteFont* font, | 79 IDWriteFont* font, |
80 IDWriteFontFamily* fontFamily, | 80 IDWriteFontFamily* fontFamily, |
81 IDWriteFontFileLoader* fontFileLoader = nu
llptr, | 81 IDWriteFontFileLoader* fontFileLoader = nu
llptr, |
82 IDWriteFontCollectionLoader* fontCollectio
nLoader = nullptr) { | 82 IDWriteFontCollectionLoader* fontCollectio
nLoader = nullptr) { |
83 SkFontID fontID = SkTypefaceCache::NewFontID(); | 83 return new DWriteFontTypeface(get_style(font), factory, fontFace, font,
fontFamily, |
84 return new DWriteFontTypeface(get_style(font), fontID, factory, fontFace
, font, fontFamily, | |
85 fontFileLoader, fontCollectionLoader); | 84 fontFileLoader, fontCollectionLoader); |
86 } | 85 } |
87 | 86 |
88 protected: | 87 protected: |
89 void weak_dispose() const override { | 88 void weak_dispose() const override { |
90 if (fDWriteFontCollectionLoader.get()) { | 89 if (fDWriteFontCollectionLoader.get()) { |
91 HRV(fFactory->UnregisterFontCollectionLoader(fDWriteFontCollectionLo
ader.get())); | 90 HRV(fFactory->UnregisterFontCollectionLoader(fDWriteFontCollectionLo
ader.get())); |
92 } | 91 } |
93 if (fDWriteFontFileLoader.get()) { | 92 if (fDWriteFontFileLoader.get()) { |
94 HRV(fFactory->UnregisterFontFileLoader(fDWriteFontFileLoader.get()))
; | 93 HRV(fFactory->UnregisterFontFileLoader(fDWriteFontFileLoader.get()))
; |
(...skipping 18 matching lines...) Expand all Loading... |
113 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; | 112 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; |
114 int onGetTableTags(SkFontTableTag tags[]) const override; | 113 int onGetTableTags(SkFontTableTag tags[]) const override; |
115 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 114 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
116 size_t length, void* data) const override; | 115 size_t length, void* data) const override; |
117 | 116 |
118 private: | 117 private: |
119 typedef SkTypeface INHERITED; | 118 typedef SkTypeface INHERITED; |
120 }; | 119 }; |
121 | 120 |
122 #endif | 121 #endif |
OLD | NEW |