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

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

Issue 420333002: Fix debug output compile error and minor style nits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 | « 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 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 #include "SkFontConfigParser_android.h" 8 #include "SkFontConfigParser_android.h"
9 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost_FreeType_common.h" 10 #include "SkFontHost_FreeType_common.h"
(...skipping 23 matching lines...) Expand all
34 #endif 34 #endif
35 35
36 class SkTypeface_Android : public SkTypeface_FreeType { 36 class SkTypeface_Android : public SkTypeface_FreeType {
37 public: 37 public:
38 SkTypeface_Android(int index, 38 SkTypeface_Android(int index,
39 Style style, 39 Style style,
40 bool isFixedPitch, 40 bool isFixedPitch,
41 const SkString familyName) 41 const SkString familyName)
42 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) 42 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch)
43 , fIndex(index) 43 , fIndex(index)
44 , fFamilyName(familyName) 44 , fFamilyName(familyName) { }
45 { }
46 45
47 const SkString& name() const { return fFamilyName; } 46 const SkString& name() const { return fFamilyName; }
48 47
49 protected: 48 protected:
50 int fIndex; 49 int fIndex;
51 SkString fFamilyName; 50 SkString fFamilyName;
52 51
53 private: 52 private:
54 typedef SkTypeface_FreeType INHERITED; 53 typedef SkTypeface_FreeType INHERITED;
55 }; 54 };
56 55
57 class SkTypeface_AndroidSystem : public SkTypeface_Android { 56 class SkTypeface_AndroidSystem : public SkTypeface_Android {
58 public: 57 public:
59 SkTypeface_AndroidSystem(const SkString pathName, 58 SkTypeface_AndroidSystem(const SkString pathName,
60 int index, 59 int index,
61 Style style, 60 Style style,
62 bool isFixedPitch, 61 bool isFixedPitch,
63 const SkString familyName) 62 const SkString familyName)
64 : INHERITED(index, style, isFixedPitch, familyName) 63 : INHERITED(index, style, isFixedPitch, familyName)
65 , fPathName(pathName) 64 , fPathName(pathName) { }
66 { }
67 65
68 virtual void onGetFontDescriptor(SkFontDescriptor* desc, 66 virtual void onGetFontDescriptor(SkFontDescriptor* desc,
69 bool* serialize) const SK_OVERRIDE 67 bool* serialize) const SK_OVERRIDE {
70 {
71 SkASSERT(desc); 68 SkASSERT(desc);
72 SkASSERT(serialize); 69 SkASSERT(serialize);
73 desc->setFamilyName(fFamilyName.c_str()); 70 desc->setFamilyName(fFamilyName.c_str());
74 desc->setFontFileName(fPathName.c_str()); 71 desc->setFontFileName(fPathName.c_str());
75 *serialize = false; 72 *serialize = false;
76 } 73 }
77 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { 74 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
78 *ttcIndex = fIndex; 75 *ttcIndex = fIndex;
79 return SkStream::NewFromFile(fPathName.c_str()); 76 return SkStream::NewFromFile(fPathName.c_str());
80 } 77 }
81 78
82 private: 79 private:
83 SkString fPathName; 80 SkString fPathName;
84 81
85 typedef SkTypeface_Android INHERITED; 82 typedef SkTypeface_Android INHERITED;
86 }; 83 };
87 84
88 class SkTypeface_AndroidStream : public SkTypeface_Android { 85 class SkTypeface_AndroidStream : public SkTypeface_Android {
89 public: 86 public:
90 SkTypeface_AndroidStream(SkStream* stream, 87 SkTypeface_AndroidStream(SkStream* stream,
91 int index, 88 int index,
92 Style style, 89 Style style,
93 bool isFixedPitch, 90 bool isFixedPitch,
94 const SkString familyName) 91 const SkString familyName)
95 : INHERITED(index, style, isFixedPitch, familyName) 92 : INHERITED(index, style, isFixedPitch, familyName)
96 , fStream(stream) 93 , fStream(stream) { }
97 { }
98 94
99 virtual void onGetFontDescriptor(SkFontDescriptor* desc, 95 virtual void onGetFontDescriptor(SkFontDescriptor* desc,
100 bool* serialize) const SK_OVERRIDE { 96 bool* serialize) const SK_OVERRIDE {
101 SkASSERT(desc); 97 SkASSERT(desc);
102 SkASSERT(serialize); 98 SkASSERT(serialize);
103 desc->setFamilyName(fFamilyName.c_str()); 99 desc->setFamilyName(fFamilyName.c_str());
104 desc->setFontFileName(NULL); 100 desc->setFontFileName(NULL);
105 *serialize = true; 101 *serialize = true;
106 } 102 }
107 103
(...skipping 19 matching lines...) Expand all
127 explicit SkFontStyleSet_Android(FontFamily* family) : fFontFamily(family) { 123 explicit SkFontStyleSet_Android(FontFamily* family) : fFontFamily(family) {
128 // TODO? make this lazy 124 // TODO? make this lazy
129 for (int i = 0; i < family->fFontFiles.count(); ++i) { 125 for (int i = 0; i < family->fFontFiles.count(); ++i) {
130 const SkString& fileName = family->fFontFiles[i].fFileName; 126 const SkString& fileName = family->fFontFiles[i].fFileName;
131 127
132 SkString pathName; 128 SkString pathName;
133 get_path_for_sys_fonts(&pathName, fileName); 129 get_path_for_sys_fonts(&pathName, fileName);
134 130
135 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(pathName.c_str() )); 131 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(pathName.c_str() ));
136 if (!stream.get()) { 132 if (!stream.get()) {
137 DEBUG_FONT(("---- SystemFonts[%d] file=%s (NOT EXIST)", i, filen ame.c_str())); 133 DEBUG_FONT(("---- SystemFonts[%d] file=%s (NOT EXIST)", i, fileN ame.c_str()));
138 continue; 134 continue;
139 } 135 }
140 136
141 SkString fontName; 137 SkString fontName;
142 SkTypeface::Style style; 138 SkTypeface::Style style;
143 bool isFixedWidth; 139 bool isFixedWidth;
144 if (!SkTypeface_FreeType::ScanFont(stream.get(), family->fFontFiles[ i].fIndex, 140 if (!SkTypeface_FreeType::ScanFont(stream.get(), family->fFontFiles[ i].fIndex,
145 &fontName, &style, &isFixedWidth) ) 141 &fontName, &style, &isFixedWidth) ) {
146 { 142 DEBUG_FONT(("---- SystemFonts[%d] file=%s (INVALID)", i, fileNam e.c_str()));
147 DEBUG_FONT(("---- SystemFonts[%d] file=%s (INVALID)", i, filenam e.c_str()));
148 continue; 143 continue;
149 } 144 }
150 145
151 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem, 146 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem,
152 (pathName, 0, 147 (pathName, 0,
153 style, isFixedWidth, fontName) )); 148 style, isFixedWidth, fontName) ));
154 } 149 }
155 } 150 }
156 151
157 virtual int count() SK_OVERRIDE { 152 virtual int count() SK_OVERRIDE {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 392 }
398 393
399 typedef SkFontMgr INHERITED; 394 typedef SkFontMgr INHERITED;
400 }; 395 };
401 396
402 /////////////////////////////////////////////////////////////////////////////// 397 ///////////////////////////////////////////////////////////////////////////////
403 398
404 SkFontMgr* SkFontMgr::Factory() { 399 SkFontMgr* SkFontMgr::Factory() {
405 return SkNEW(SkFontMgr_Android); 400 return SkNEW(SkFontMgr_Android);
406 } 401 }
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