OLD | NEW |
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ui/gfx/font.h" | 9 #include "ui/gfx/font.h" |
10 #include "ui/gfx/linux_font_delegate.h" | 10 #include "ui/gfx/linux_font_delegate.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 if (family_out) { | 80 if (family_out) { |
81 FcChar8* family = NULL; | 81 FcChar8* family = NULL; |
82 FcPatternGetString(match, FC_FAMILY, 0, &family); | 82 FcPatternGetString(match, FC_FAMILY, 0, &family); |
83 if (family) | 83 if (family) |
84 family_out->assign(reinterpret_cast<const char*>(family)); | 84 family_out->assign(reinterpret_cast<const char*>(family)); |
85 } | 85 } |
86 | 86 |
87 if (params_out) { | 87 if (params_out) { |
88 FcBool fc_antialias = 0; | 88 FcBool fc_antialias = 0; |
89 FcPatternGetBool(match, FC_ANTIALIAS, 0, &fc_antialias); | 89 if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &fc_antialias) == |
90 params_out->antialiasing = fc_antialias; | 90 FcResultMatch) { |
| 91 params_out->antialiasing = fc_antialias; |
| 92 } |
91 | 93 |
92 FcBool fc_autohint = 0; | 94 FcBool fc_autohint = 0; |
93 FcPatternGetBool(match, FC_AUTOHINT, 0, &fc_autohint); | 95 if (FcPatternGetBool(match, FC_AUTOHINT, 0, &fc_autohint) == |
94 params_out->autohinter = fc_autohint; | 96 FcResultMatch) { |
| 97 params_out->autohinter = fc_autohint; |
| 98 } |
95 | 99 |
96 FcBool fc_bitmap = 0; | 100 FcBool fc_bitmap = 0; |
97 FcPatternGetBool(match, FC_EMBEDDED_BITMAP, 0, &fc_bitmap); | 101 if (FcPatternGetBool(match, FC_EMBEDDED_BITMAP, 0, &fc_bitmap) == |
98 params_out->use_bitmaps = fc_bitmap; | 102 FcResultMatch) { |
| 103 params_out->use_bitmaps = fc_bitmap; |
| 104 } |
99 | 105 |
100 FcBool fc_hinting = 0; | 106 FcBool fc_hinting = 0; |
101 int fc_hint_style = FC_HINT_NONE; | 107 if (FcPatternGetBool(match, FC_HINTING, 0, &fc_hinting) == FcResultMatch) { |
102 FcPatternGetBool(match, FC_HINTING, 0, &fc_hinting); | 108 int fc_hint_style = FC_HINT_NONE; |
103 if (fc_hinting) | 109 if (fc_hinting) |
104 FcPatternGetInteger(match, FC_HINT_STYLE, 0, &fc_hint_style); | 110 FcPatternGetInteger(match, FC_HINT_STYLE, 0, &fc_hint_style); |
105 params_out->hinting = ConvertFontconfigHintStyle(fc_hint_style); | 111 params_out->hinting = ConvertFontconfigHintStyle(fc_hint_style); |
| 112 } |
106 | 113 |
107 int fc_rgba = FC_RGBA_NONE; | 114 int fc_rgba = FC_RGBA_NONE; |
108 FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba); | 115 if (FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba) == FcResultMatch) |
109 params_out->subpixel_rendering = ConvertFontconfigRgba(fc_rgba); | 116 params_out->subpixel_rendering = ConvertFontconfigRgba(fc_rgba); |
110 } | 117 } |
111 | 118 |
112 FcPatternDestroy(match); | 119 FcPatternDestroy(match); |
113 return true; | 120 return true; |
114 } | 121 } |
115 | 122 |
116 // Returns the system's default settings. | 123 // Returns the system's default settings. |
117 FontRenderParams LoadDefaults(bool for_web_contents) { | 124 FontRenderParams LoadDefaults(bool for_web_contents) { |
118 return GetCustomFontRenderParams( | 125 return GetCustomFontRenderParams( |
119 for_web_contents, NULL, NULL, NULL, NULL, NULL); | 126 for_web_contents, NULL, NULL, NULL, NULL, NULL); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 168 |
162 // Use the first family from the list if Fontconfig didn't suggest a family. | 169 // Use the first family from the list if Fontconfig didn't suggest a family. |
163 if (family_out && family_out->empty() && | 170 if (family_out && family_out->empty() && |
164 family_list && !family_list->empty()) | 171 family_list && !family_list->empty()) |
165 *family_out = (*family_list)[0]; | 172 *family_out = (*family_list)[0]; |
166 | 173 |
167 return params; | 174 return params; |
168 } | 175 } |
169 | 176 |
170 } // namespace gfx | 177 } // namespace gfx |
OLD | NEW |