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

Side by Side Diff: trunk/src/ports/SkFontHost_fontconfig.cpp

Issue 12623011: add (temp) SkFontLCDConfig class to hold LCD getters/setters. This will allow (Closed) Base URL: http://skia.googlecode.com/svn/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/core/SkFontHost.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 2008 Google Inc. 2 * Copyright 2008 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 "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost.h" 10 #include "SkFontHost.h"
(...skipping 24 matching lines...) Expand all
35 // convenience function to create the direct interface if none is installed. 35 // convenience function to create the direct interface if none is installed.
36 extern SkFontConfigInterface* SkCreateDirectFontConfigInterface(); 36 extern SkFontConfigInterface* SkCreateDirectFontConfigInterface();
37 37
38 static SkFontConfigInterface* RefFCI() { 38 static SkFontConfigInterface* RefFCI() {
39 for (;;) { 39 for (;;) {
40 SkFontConfigInterface* fci = SkFontConfigInterface::RefGlobal(); 40 SkFontConfigInterface* fci = SkFontConfigInterface::RefGlobal();
41 if (fci) { 41 if (fci) {
42 return fci; 42 return fci;
43 } 43 }
44 fci = SkFontConfigInterface::GetSingletonDirectInterface(); 44 fci = SkFontConfigInterface::GetSingletonDirectInterface();
45 SkFontConfigInterface::SetGlobal(fci); 45 SkFontConfigInterface::SetGlobal(fci)->unref();
46 } 46 }
47 } 47 }
48 48
49 class FontConfigTypeface : public SkTypeface { 49 class FontConfigTypeface : public SkTypeface {
50 SkFontConfigInterface::FontIdentity fIdentity; 50 SkFontConfigInterface::FontIdentity fIdentity;
51 SkString fFamilyName; 51 SkString fFamilyName;
52 SkStream* fLocalStream; 52 SkStream* fLocalStream;
53 53
54 public: 54 public:
55 FontConfigTypeface(Style style, 55 FontConfigTypeface(Style style,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 if (familyFace) { 123 if (familyFace) {
124 FontConfigTypeface* fct = (FontConfigTypeface*)familyFace; 124 FontConfigTypeface* fct = (FontConfigTypeface*)familyFace;
125 familyName = fct->getFamilyName(); 125 familyName = fct->getFamilyName();
126 } 126 }
127 127
128 FindRec rec(familyName, style); 128 FindRec rec(familyName, style);
129 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec); 129 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec);
130 if (face) { 130 if (face) {
131 SkDebugf("found cached face <%s> <%s> %p [%d]\n", familyName, ((FontConf igTypeface*)face)->getFamilyName(), face, face->getRefCnt());
131 return face; 132 return face;
132 } 133 }
133 134
134 SkFontConfigInterface::FontIdentity indentity; 135 SkFontConfigInterface::FontIdentity indentity;
135 SkString outFamilyName; 136 SkString outFamilyName;
136 SkTypeface::Style outStyle; 137 SkTypeface::Style outStyle;
137 138
138 if (!fci->matchFamilyName(familyName, style, 139 if (!fci->matchFamilyName(familyName, style,
139 &indentity, &outFamilyName, &outStyle)) { 140 &indentity, &outFamilyName, &outStyle)) {
140 return NULL; 141 return NULL;
141 } 142 }
142 143
143 face = SkNEW_ARGS(FontConfigTypeface, (outStyle, indentity, outFamilyName)); 144 face = SkNEW_ARGS(FontConfigTypeface, (outStyle, indentity, outFamilyName));
144 SkTypefaceCache::Add(face, style); 145 SkTypefaceCache::Add(face, style);
146 SkDebugf("add face <%s> <%s> %p [%d]\n", familyName, outFamilyName.c_str(), face, face->getRefCnt());
145 return face; 147 return face;
146 } 148 }
147 149
148 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { 150 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
149 if (!stream) { 151 if (!stream) {
150 return NULL; 152 return NULL;
151 } 153 }
152 const size_t length = stream->getLength(); 154 const size_t length = stream->getLength();
153 if (!length) { 155 if (!length) {
154 return NULL; 156 return NULL;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return stream.get() 314 return stream.get()
313 ? SkFontStream::GetTableData(stream, ttcIndex, 315 ? SkFontStream::GetTableData(stream, ttcIndex,
314 tag, offset, length, data) 316 tag, offset, length, data)
315 : 0; 317 : 0;
316 } 318 }
317 319
318 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const { 320 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const {
319 desc->setStyle(this->style()); 321 desc->setStyle(this->style());
320 desc->setFamilyName(this->getFamilyName()); 322 desc->setFamilyName(this->getFamilyName());
321 } 323 }
OLDNEW
« no previous file with comments | « trunk/src/core/SkFontHost.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698