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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (family_out) | 121 if (family_out) |
122 family_out->clear(); | 122 family_out->clear(); |
123 | 123 |
124 // Start with the delegate's settings, but let Fontconfig have the final say. | 124 // Start with the delegate's settings, but let Fontconfig have the final say. |
125 FontRenderParams params; | 125 FontRenderParams params; |
126 const LinuxFontDelegate* delegate = LinuxFontDelegate::instance(); | 126 const LinuxFontDelegate* delegate = LinuxFontDelegate::instance(); |
127 if (delegate) | 127 if (delegate) |
128 params = delegate->GetDefaultFontRenderParams(); | 128 params = delegate->GetDefaultFontRenderParams(); |
129 QueryFontconfig(query, ¶ms, family_out); | 129 QueryFontconfig(query, ¶ms, family_out); |
130 | 130 |
131 // Fontconfig doesn't support configuring subpixel positioning; check a flag. | 131 if (!params.antialiasing) { |
132 params.subpixel_positioning = CommandLine::ForCurrentProcess()->HasSwitch( | 132 // Cairo forces full hinting when antialiasing is disabled, since anything |
133 query.for_web_contents ? | 133 // less than that looks awful; do the same here. Requesting subpixel |
134 switches::kEnableWebkitTextSubpixelPositioning : | 134 // rendering or positioning doesn't make sense either. |
135 switches::kEnableBrowserTextSubpixelPositioning); | 135 params.hinting = FontRenderParams::HINTING_FULL; |
| 136 params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE; |
| 137 params.subpixel_positioning = false; |
| 138 } else { |
| 139 // Fontconfig doesn't support configuring subpixel positioning; check a |
| 140 // flag. |
| 141 params.subpixel_positioning = CommandLine::ForCurrentProcess()->HasSwitch( |
| 142 query.for_web_contents ? |
| 143 switches::kEnableWebkitTextSubpixelPositioning : |
| 144 switches::kEnableBrowserTextSubpixelPositioning); |
136 | 145 |
137 // To enable subpixel positioning, we need to disable hinting. | 146 // To enable subpixel positioning, we need to disable hinting. |
138 if (params.subpixel_positioning) | 147 if (params.subpixel_positioning) |
139 params.hinting = FontRenderParams::HINTING_NONE; | 148 params.hinting = FontRenderParams::HINTING_NONE; |
| 149 } |
140 | 150 |
141 // Use the first family from the list if Fontconfig didn't suggest a family. | 151 // Use the first family from the list if Fontconfig didn't suggest a family. |
142 if (family_out && family_out->empty() && !query.families.empty()) | 152 if (family_out && family_out->empty() && !query.families.empty()) |
143 *family_out = query.families[0]; | 153 *family_out = query.families[0]; |
144 | 154 |
145 return params; | 155 return params; |
146 } | 156 } |
147 | 157 |
148 } // namespace gfx | 158 } // namespace gfx |
OLD | NEW |