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

Side by Side Diff: skia/ext/SkFontHost_fontconfig.cpp

Issue 147005: Linux: fix fake italics for font's without italic variants. (Closed)
Patch Set: ... Created 11 years, 6 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 /* libs/graphics/ports/SkFontHost_fontconfig.cpp 1 /* libs/graphics/ports/SkFontHost_fontconfig.cpp
2 ** 2 **
3 ** Copyright 2008, Google Inc. 3 ** Copyright 2008, Google Inc.
4 ** 4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License"); 5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License. 6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at 7 ** You may obtain a copy of the License at
8 ** 8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0 9 ** http://www.apache.org/licenses/LICENSE-2.0
10 ** 10 **
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 SkTypeface::Style style) 94 SkTypeface::Style style)
95 { 95 {
96 std::string resolved_family_name; 96 std::string resolved_family_name;
97 97
98 if (familyFace) { 98 if (familyFace) {
99 // Given the fileid we can ask fontconfig for the familyname of the 99 // Given the fileid we can ask fontconfig for the familyname of the
100 // font. 100 // font.
101 const unsigned fileid = UniqueIdToFileId(familyFace->uniqueID()); 101 const unsigned fileid = UniqueIdToFileId(familyFace->uniqueID());
102 if (!GetFcImpl()->Match( 102 if (!GetFcImpl()->Match(
103 &resolved_family_name, NULL, true /* fileid valid */, fileid, "", 103 &resolved_family_name, NULL, true /* fileid valid */, fileid, "",
104 -1, -1)) { 104 NULL, NULL)) {
105 return NULL; 105 return NULL;
106 } 106 }
107 } else if (familyName) { 107 } else if (familyName) {
108 resolved_family_name = familyName; 108 resolved_family_name = familyName;
109 } else { 109 } else {
110 return NULL; 110 return NULL;
111 } 111 }
112 112
113 const bool bold = style & SkTypeface::kBold; 113 bool bold = style & SkTypeface::kBold;
114 const bool italic = style & SkTypeface::kItalic; 114 bool italic = style & SkTypeface::kItalic;
115 unsigned fileid; 115 unsigned fileid;
116 if (!GetFcImpl()->Match(NULL, &fileid, false, -1, /* no fileid */ 116 if (!GetFcImpl()->Match(NULL, &fileid, false, -1, /* no fileid */
117 resolved_family_name, bold, italic)) { 117 resolved_family_name, &bold, &italic)) {
118 return NULL; 118 return NULL;
119 } 119 }
120 const SkTypeface::Style resulting_style = static_cast<SkTypeface::Style>(
121 (bold ? SkTypeface::kBold : 0) |
122 (italic ? SkTypeface::kItalic : 0));
120 123
121 const unsigned id = FileIdAndStyleToUniqueId(fileid, style); 124 const unsigned id = FileIdAndStyleToUniqueId(fileid, resulting_style);
122 SkTypeface* typeface = SkNEW_ARGS(FontConfigTypeface, (style, id)); 125 SkTypeface* typeface = SkNEW_ARGS(FontConfigTypeface, (resulting_style, id)) ;
123 126
124 { 127 {
125 SkAutoMutexAcquire ac(global_fc_map_lock); 128 SkAutoMutexAcquire ac(global_fc_map_lock);
126 global_fc_typefaces[id] = typeface; 129 global_fc_typefaces[id] = typeface;
127 } 130 }
128 131
129 return typeface; 132 return typeface;
130 } 133 }
131 134
132 // static 135 // static
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return SkNEW_ARGS(SkFileDescriptorStream, (fd)); 231 return SkNEW_ARGS(SkFileDescriptorStream, (fd));
229 } 232 }
230 233
231 size_t SkFontHost::ShouldPurgeFontCache(size_t sizeAllocatedSoFar) 234 size_t SkFontHost::ShouldPurgeFontCache(size_t sizeAllocatedSoFar)
232 { 235 {
233 if (sizeAllocatedSoFar > kFontCacheMemoryBudget) 236 if (sizeAllocatedSoFar > kFontCacheMemoryBudget)
234 return sizeAllocatedSoFar - kFontCacheMemoryBudget; 237 return sizeAllocatedSoFar - kFontCacheMemoryBudget;
235 else 238 else
236 return 0; // nothing to do 239 return 0; // nothing to do
237 } 240 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_sandbox_host_linux.cc ('k') | skia/ext/SkFontHost_fontconfig_direct.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698