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

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

Issue 1936213002: Clean up SkFontConfigInterface implementation. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkOnce Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkFontConfigInterface.h" 8 #include "SkFontConfigInterface.h"
9 #include "SkFontHost_FreeType_common.h" 9 #include "SkFontHost_FreeType_common.h"
10 #include "SkStream.h" 10 #include "SkStream.h"
11 #include "SkTypefaceCache.h" 11 #include "SkTypefaceCache.h"
12 12
13 class SkFontDescriptor; 13 class SkFontDescriptor;
14 14
15 class FontConfigTypeface : public SkTypeface_FreeType { 15 class SkTypeface_FCI : public SkTypeface_FreeType {
16 SkAutoTUnref<SkFontConfigInterface> fFCI;
16 SkFontConfigInterface::FontIdentity fIdentity; 17 SkFontConfigInterface::FontIdentity fIdentity;
17 SkString fFamilyName; 18 SkString fFamilyName;
18 SkAutoTDelete<SkStreamAsset> fLocalStream; 19 SkAutoTDelete<SkStreamAsset> fLocalStream;
19 20
20 public: 21 public:
21 static FontConfigTypeface* Create(const SkFontStyle& style, 22 static SkTypeface_FCI* Create(SkFontConfigInterface* fci,
22 const SkFontConfigInterface::FontIdentity& fi, 23 const SkFontConfigInterface::FontIdentity& fi,
23 const SkString& familyName) { 24 const SkString& familyName,
24 return new FontConfigTypeface(style, fi, familyName); 25 const SkFontStyle& style)
26 {
27 return new SkTypeface_FCI(fci, fi, familyName, style);
25 } 28 }
26 29
27 static FontConfigTypeface* Create(const SkFontStyle& style, bool fixedWidth, 30 static SkTypeface_FCI* Create(const SkFontStyle& style, bool fixedWidth,
28 SkStreamAsset* localStream) { 31 SkStreamAsset* localStream, int index)
29 return new FontConfigTypeface(style, fixedWidth, localStream); 32 {
33 return new SkTypeface_FCI(style, fixedWidth, localStream, index);
30 } 34 }
31 35
32 const SkFontConfigInterface::FontIdentity& getIdentity() const { 36 const SkFontConfigInterface::FontIdentity& getIdentity() const {
33 return fIdentity; 37 return fIdentity;
34 } 38 }
35 39
36 SkStreamAsset* getLocalStream() const { return fLocalStream.get(); } 40 SkStreamAsset* getLocalStream() const {
41 return fLocalStream.get();
42 }
37 43
38 bool isFamilyName(const char* name) const { 44 bool isFamilyName(const char* name) const {
39 return fFamilyName.equals(name); 45 return fFamilyName.equals(name);
40 } 46 }
41 47
42 static SkTypeface* LegacyCreateTypeface(const char familyName[], SkFontStyle );
43
44 protected: 48 protected:
45 FontConfigTypeface(const SkFontStyle& style, 49 SkTypeface_FCI(SkFontConfigInterface* fci,
46 const SkFontConfigInterface::FontIdentity& fi, 50 const SkFontConfigInterface::FontIdentity& fi,
47 const SkString& familyName) 51 const SkString& familyName,
52 const SkFontStyle& style)
48 : INHERITED(style, SkTypefaceCache::NewFontID(), false) 53 : INHERITED(style, SkTypefaceCache::NewFontID(), false)
54 , fFCI(SkRef(fci))
49 , fIdentity(fi) 55 , fIdentity(fi)
50 , fFamilyName(familyName) 56 , fFamilyName(familyName)
51 , fLocalStream(nullptr) {} 57 , fLocalStream(nullptr) {}
52 58
53 FontConfigTypeface(const SkFontStyle& style, bool fixedWidth, SkStreamAsset* localStream) 59 SkTypeface_FCI(const SkFontStyle& style, bool fixedWidth, SkStreamAsset* loc alStream, int index)
54 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) 60 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth)
55 , fLocalStream(localStream) { 61 , fLocalStream(localStream)
56 // we default to empty fFamilyName and fIdentity 62 {
63 fIdentity.fTTCIndex = index;
57 } 64 }
58 65
59 void onGetFamilyName(SkString* familyName) const override; 66 void onGetFamilyName(SkString* familyName) const override { *familyName = fF amilyName; }
60 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; 67 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override;
61 SkStreamAsset* onOpenStream(int* ttcIndex) const override; 68 SkStreamAsset* onOpenStream(int* ttcIndex) const override;
62 69
63 private: 70 private:
64 typedef SkTypeface_FreeType INHERITED; 71 typedef SkTypeface_FreeType INHERITED;
65 }; 72 };
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigInterface_direct_google3_factory.cpp ('k') | src/ports/SkFontHost_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698