| 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 "content/child/browser_font_resource_trusted.h" | 5 #include "content/child/browser_font_resource_trusted.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/public/common/web_preferences.h" | 9 #include "content/public/common/web_preferences.h" |
| 10 #include "ppapi/c/dev/ppb_font_dev.h" | 10 #include "ppapi/c/dev/ppb_font_dev.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 194 } |
| 195 result.family = resolved_family; | 195 result.family = resolved_family; |
| 196 | 196 |
| 197 result.genericFamily = PP_FAMILY_TO_WEB_FAMILY(font.family); | 197 result.genericFamily = PP_FAMILY_TO_WEB_FAMILY(font.family); |
| 198 | 198 |
| 199 if (font.size == 0) { | 199 if (font.size == 0) { |
| 200 // Resolve the default font size, using the resolved family to see if | 200 // Resolve the default font size, using the resolved family to see if |
| 201 // we should use the fixed or regular font size. It's difficult at this | 201 // we should use the fixed or regular font size. It's difficult at this |
| 202 // level to detect if the requested font is fixed width, so we only apply | 202 // level to detect if the requested font is fixed width, so we only apply |
| 203 // the alternate font size to the default fixed font family. | 203 // the alternate font size to the default fixed font family. |
| 204 if (StringToLowerASCII(resolved_family) == | 204 if (base::StringToLowerASCII(resolved_family) == |
| 205 StringToLowerASCII(GetFontFromMap(prefs.fixed_font_family_map, | 205 base::StringToLowerASCII(GetFontFromMap(prefs.fixed_font_family_map, |
| 206 kCommonScript))) | 206 kCommonScript))) |
| 207 result.size = static_cast<float>(prefs.default_fixed_font_size); | 207 result.size = static_cast<float>(prefs.default_fixed_font_size); |
| 208 else | 208 else |
| 209 result.size = static_cast<float>(prefs.default_font_size); | 209 result.size = static_cast<float>(prefs.default_font_size); |
| 210 } else { | 210 } else { |
| 211 // Use the exact size. | 211 // Use the exact size. |
| 212 result.size = static_cast<float>(font.size); | 212 result.size = static_cast<float>(font.size); |
| 213 } | 213 } |
| 214 | 214 |
| 215 result.italic = font.italic != PP_FALSE; | 215 result.italic = font.italic != PP_FALSE; |
| 216 result.smallCaps = font.small_caps != PP_FALSE; | 216 result.smallCaps = font.small_caps != PP_FALSE; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 419 |
| 420 // Advance to the next run. Note that we avoid doing this for the last run | 420 // Advance to the next run. Note that we avoid doing this for the last run |
| 421 // since it's unnecessary, measuring text is slow, and most of the time | 421 // since it's unnecessary, measuring text is slow, and most of the time |
| 422 // there will be only one run anyway. | 422 // there will be only one run anyway. |
| 423 if (i != runs.num_runs() - 1) | 423 if (i != runs.num_runs() - 1) |
| 424 web_position.x += font_->calculateWidth(run); | 424 web_position.x += font_->calculateWidth(run); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace content | 428 } // namespace content |
| OLD | NEW |