OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gfx/font_util.h" | 5 #include "app/gfx/font_util.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "gfx/font.h" | 11 #include "gfx/font.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 int GetLocalizedContentsWidthForFont(int col_resource_id, | 15 int GetLocalizedContentsWidthForFont(int col_resource_id, |
16 const gfx::Font& font) { | 16 const gfx::Font& font) { |
17 double chars = 0; | 17 double chars = 0; |
18 base::StringToDouble(WideToUTF8(l10n_util::GetString(col_resource_id)), | 18 base::StringToDouble(l10n_util::GetStringUTF8(col_resource_id), &chars); |
19 &chars); | |
20 int width = font.GetExpectedTextWidth(static_cast<int>(chars)); | 19 int width = font.GetExpectedTextWidth(static_cast<int>(chars)); |
21 DCHECK_GT(width, 0); | 20 DCHECK_GT(width, 0); |
22 return width; | 21 return width; |
23 } | 22 } |
24 | 23 |
25 int GetLocalizedContentsHeightForFont(int row_resource_id, | 24 int GetLocalizedContentsHeightForFont(int row_resource_id, |
26 const gfx::Font& font) { | 25 const gfx::Font& font) { |
27 double lines = 0; | 26 double lines = 0; |
28 base::StringToDouble(WideToUTF8(l10n_util::GetString(row_resource_id)), | 27 base::StringToDouble(l10n_util::GetStringUTF8(row_resource_id), &lines); |
29 &lines); | |
30 int height = static_cast<int>(font.GetHeight() * lines); | 28 int height = static_cast<int>(font.GetHeight() * lines); |
31 DCHECK_GT(height, 0); | 29 DCHECK_GT(height, 0); |
32 return height; | 30 return height; |
33 } | 31 } |
34 | 32 |
35 gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id, | 33 gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id, |
36 int row_resource_id, | 34 int row_resource_id, |
37 const gfx::Font& font) { | 35 const gfx::Font& font) { |
38 return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font), | 36 return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font), |
39 GetLocalizedContentsHeightForFont(row_resource_id, font)); | 37 GetLocalizedContentsHeightForFont(row_resource_id, font)); |
40 } | 38 } |
41 | 39 |
42 } // namespace gfx | 40 } // namespace gfx |
OLD | NEW |