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

Side by Side Diff: src/ports/SkTypeface_win_dw.h

Issue 412993002: Get additional DW font metrics when available. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Always assert QueryInterface worked. Created 6 years, 5 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
« no previous file with comments | « src/ports/SkScalerContext_win_dw.cpp ('k') | 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 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
11 #include "SkAdvancedTypefaceMetrics.h" 11 #include "SkAdvancedTypefaceMetrics.h"
12 #include "SkDWrite.h" 12 #include "SkDWrite.h"
13 #include "SkHRESULT.h" 13 #include "SkHRESULT.h"
14 #include "SkTScopedComPtr.h" 14 #include "SkTScopedComPtr.h"
15 #include "SkTypeface.h" 15 #include "SkTypeface.h"
16 #include "SkTypefaceCache.h" 16 #include "SkTypefaceCache.h"
17 #include "SkTypes.h" 17 #include "SkTypes.h"
18 18
19 #include <dwrite.h> 19 #include <dwrite.h>
20 #include <dwrite_1.h>
20 21
21 class SkFontDescriptor; 22 class SkFontDescriptor;
22 struct SkScalerContextRec; 23 struct SkScalerContextRec;
23 24
24 static SkTypeface::Style get_style(IDWriteFont* font) { 25 static SkTypeface::Style get_style(IDWriteFont* font) {
25 int style = SkTypeface::kNormal; 26 int style = SkTypeface::kNormal;
26 DWRITE_FONT_WEIGHT weight = font->GetWeight(); 27 DWRITE_FONT_WEIGHT weight = font->GetWeight();
27 if (DWRITE_FONT_WEIGHT_DEMI_BOLD <= weight) { 28 if (DWRITE_FONT_WEIGHT_DEMI_BOLD <= weight) {
28 style |= SkTypeface::kBold; 29 style |= SkTypeface::kBold;
29 } 30 }
(...skipping 13 matching lines...) Expand all
43 IDWriteFontFamily* fontFamily, 44 IDWriteFontFamily* fontFamily,
44 IDWriteFontFileLoader* fontFileLoader = NULL, 45 IDWriteFontFileLoader* fontFileLoader = NULL,
45 IDWriteFontCollectionLoader* fontCollectionLoader = NULL) 46 IDWriteFontCollectionLoader* fontCollectionLoader = NULL)
46 : SkTypeface(style, fontID, false) 47 : SkTypeface(style, fontID, false)
47 , fFactory(SkRefComPtr(factory)) 48 , fFactory(SkRefComPtr(factory))
48 , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader)) 49 , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader))
49 , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader)) 50 , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader))
50 , fDWriteFontFamily(SkRefComPtr(fontFamily)) 51 , fDWriteFontFamily(SkRefComPtr(fontFamily))
51 , fDWriteFont(SkRefComPtr(font)) 52 , fDWriteFont(SkRefComPtr(font))
52 , fDWriteFontFace(SkRefComPtr(fontFace)) 53 , fDWriteFontFace(SkRefComPtr(fontFace))
53 { } 54 {
55 if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
56 // IUnknown::QueryInterface states that if it fails, punk will be se t to NULL.
57 // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
58 SK_ALWAYSBREAK(NULL == fDWriteFontFace1.get());
59 }
60 }
54 61
55 public: 62 public:
56 SkTScopedComPtr<IDWriteFactory> fFactory; 63 SkTScopedComPtr<IDWriteFactory> fFactory;
57 SkTScopedComPtr<IDWriteFontCollectionLoader> fDWriteFontCollectionLoader; 64 SkTScopedComPtr<IDWriteFontCollectionLoader> fDWriteFontCollectionLoader;
58 SkTScopedComPtr<IDWriteFontFileLoader> fDWriteFontFileLoader; 65 SkTScopedComPtr<IDWriteFontFileLoader> fDWriteFontFileLoader;
59 SkTScopedComPtr<IDWriteFontFamily> fDWriteFontFamily; 66 SkTScopedComPtr<IDWriteFontFamily> fDWriteFontFamily;
60 SkTScopedComPtr<IDWriteFont> fDWriteFont; 67 SkTScopedComPtr<IDWriteFont> fDWriteFont;
61 SkTScopedComPtr<IDWriteFontFace> fDWriteFontFace; 68 SkTScopedComPtr<IDWriteFontFace> fDWriteFontFace;
69 SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1;
62 70
63 static DWriteFontTypeface* Create(IDWriteFactory* factory, 71 static DWriteFontTypeface* Create(IDWriteFactory* factory,
64 IDWriteFontFace* fontFace, 72 IDWriteFontFace* fontFace,
65 IDWriteFont* font, 73 IDWriteFont* font,
66 IDWriteFontFamily* fontFamily, 74 IDWriteFontFamily* fontFamily,
67 IDWriteFontFileLoader* fontFileLoader = NU LL, 75 IDWriteFontFileLoader* fontFileLoader = NU LL,
68 IDWriteFontCollectionLoader* fontCollectio nLoader = NULL) { 76 IDWriteFontCollectionLoader* fontCollectio nLoader = NULL) {
69 SkTypeface::Style style = get_style(font); 77 SkTypeface::Style style = get_style(font);
70 SkFontID fontID = SkTypefaceCache::NewFontID(); 78 SkFontID fontID = SkTypefaceCache::NewFontID();
71 return SkNEW_ARGS(DWriteFontTypeface, (style, fontID, 79 return SkNEW_ARGS(DWriteFontTypeface, (style, fontID,
(...skipping 28 matching lines...) Expand all
100 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_ OVERRIDE; 108 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_ OVERRIDE;
101 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; 109 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
102 virtual size_t onGetTableData(SkFontTableTag, size_t offset, 110 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
103 size_t length, void* data) const SK_OVERRIDE; 111 size_t length, void* data) const SK_OVERRIDE;
104 112
105 private: 113 private:
106 typedef SkTypeface INHERITED; 114 typedef SkTypeface INHERITED;
107 }; 115 };
108 116
109 #endif 117 #endif
OLDNEW
« no previous file with comments | « src/ports/SkScalerContext_win_dw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698