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

Side by Side Diff: ui/gfx/font_render_params_linux.cc

Issue 523763003: ABANDONED: linux: Avoid bitmaps for Cambria, Calibri, and Consolas. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix strcasecmp() calls Created 6 years, 3 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/font_render_params.h" 5 #include "ui/gfx/font_render_params.h"
6 6
7 #include <fontconfig/fontconfig.h> 7 #include <fontconfig/fontconfig.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/mru_cache.h" 10 #include "base/containers/mru_cache.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 FcConfigSubstitute(NULL, pattern, FcMatchPattern); 107 FcConfigSubstitute(NULL, pattern, FcMatchPattern);
108 FcDefaultSubstitute(pattern); 108 FcDefaultSubstitute(pattern);
109 FcResult result; 109 FcResult result;
110 FcPattern* match = FcFontMatch(NULL, pattern, &result); 110 FcPattern* match = FcFontMatch(NULL, pattern, &result);
111 FcPatternDestroy(pattern); 111 FcPatternDestroy(pattern);
112 if (!match) 112 if (!match)
113 return false; 113 return false;
114 114
115 if (family_out) { 115 FcChar8* family = NULL;
116 FcChar8* family = NULL; 116 FcPatternGetString(match, FC_FAMILY, 0, &family);
117 FcPatternGetString(match, FC_FAMILY, 0, &family); 117 if (family && family_out)
118 if (family) 118 family_out->assign(reinterpret_cast<const char*>(family));
119 family_out->assign(reinterpret_cast<const char*>(family));
120 }
121 119
122 if (params_out) { 120 if (params_out) {
123 FcBool fc_antialias = 0; 121 FcBool fc_antialias = 0;
124 if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &fc_antialias) == 122 if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &fc_antialias) ==
125 FcResultMatch) { 123 FcResultMatch) {
126 params_out->antialiasing = fc_antialias; 124 params_out->antialiasing = fc_antialias;
127 } 125 }
128 126
129 FcBool fc_autohint = 0; 127 FcBool fc_autohint = 0;
130 if (FcPatternGetBool(match, FC_AUTOHINT, 0, &fc_autohint) == 128 if (FcPatternGetBool(match, FC_AUTOHINT, 0, &fc_autohint) ==
(...skipping 11 matching lines...) Expand all
142 if (FcPatternGetBool(match, FC_HINTING, 0, &fc_hinting) == FcResultMatch) { 140 if (FcPatternGetBool(match, FC_HINTING, 0, &fc_hinting) == FcResultMatch) {
143 int fc_hint_style = FC_HINT_NONE; 141 int fc_hint_style = FC_HINT_NONE;
144 if (fc_hinting) 142 if (fc_hinting)
145 FcPatternGetInteger(match, FC_HINT_STYLE, 0, &fc_hint_style); 143 FcPatternGetInteger(match, FC_HINT_STYLE, 0, &fc_hint_style);
146 params_out->hinting = ConvertFontconfigHintStyle(fc_hint_style); 144 params_out->hinting = ConvertFontconfigHintStyle(fc_hint_style);
147 } 145 }
148 146
149 int fc_rgba = FC_RGBA_NONE; 147 int fc_rgba = FC_RGBA_NONE;
150 if (FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba) == FcResultMatch) 148 if (FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba) == FcResultMatch)
151 params_out->subpixel_rendering = ConvertFontconfigRgba(fc_rgba); 149 params_out->subpixel_rendering = ConvertFontconfigRgba(fc_rgba);
150
151 // Some Vista fonts ship with embedded bitmaps. Make sure we don't use them
152 // if antialiasing was requested: http://crbug.com/408059
153 if (params_out->antialiasing && family &&
154 (strcasecmp(reinterpret_cast<const char*>(family), "calibri") == 0 ||
155 strcasecmp(reinterpret_cast<const char*>(family), "cambria") == 0 ||
156 strcasecmp(reinterpret_cast<const char*>(family), "consolas") == 0)) {
157 params_out->use_bitmaps = false;
158 }
152 } 159 }
153 160
154 FcPatternDestroy(match); 161 FcPatternDestroy(match);
155 return true; 162 return true;
156 } 163 }
157 164
158 // Serialize |query| into a string and hash it to a value suitable for use as a 165 // Serialize |query| into a string and hash it to a value suitable for use as a
159 // cache key. 166 // cache key.
160 uint32 HashFontRenderParamsQuery(const FontRenderParamsQuery& query) { 167 uint32 HashFontRenderParamsQuery(const FontRenderParamsQuery& query) {
161 return base::Hash(base::StringPrintf("%d|%d|%d|%d|%s", 168 return base::Hash(base::StringPrintf("%d|%d|%d|%d|%s",
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 synchronized_cache->cache.Clear(); 238 synchronized_cache->cache.Clear();
232 } 239 }
233 240
234 #if defined(OS_CHROMEOS) 241 #if defined(OS_CHROMEOS)
235 void SetFontRenderParamsDeviceScaleFactor(float device_scale_factor) { 242 void SetFontRenderParamsDeviceScaleFactor(float device_scale_factor) {
236 device_scale_factor_for_internal_display = device_scale_factor; 243 device_scale_factor_for_internal_display = device_scale_factor;
237 } 244 }
238 #endif 245 #endif
239 246
240 } // namespace gfx 247 } // namespace gfx
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