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

Side by Side Diff: app/gfx/font_util.cc

Issue 1132006: Move app/gfx/canvas and app/gfx/font to gfx/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « app/gfx/font_unittest.cc ('k') | app/gfx/font_win.cc » ('j') | 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) 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/gfx/font.h"
8 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
9 #include "base/logging.h" 8 #include "base/logging.h"
10 #include "base/string_util.h" 9 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.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 StringToDouble(WideToUTF8(l10n_util::GetString(col_resource_id)), &chars); 18 StringToDouble(WideToUTF8(l10n_util::GetString(col_resource_id)), &chars);
19 int width = font.GetExpectedTextWidth(static_cast<int>(chars)); 19 int width = font.GetExpectedTextWidth(static_cast<int>(chars));
20 DCHECK_GT(width, 0); 20 DCHECK_GT(width, 0);
21 return width; 21 return width;
22 } 22 }
23 23
24 int GetLocalizedContentsHeightForFont(int row_resource_id, 24 int GetLocalizedContentsHeightForFont(int row_resource_id,
25 const gfx::Font& font) { 25 const gfx::Font& font) {
26 double lines = 0; 26 double lines = 0;
27 StringToDouble(WideToUTF8(l10n_util::GetString(row_resource_id)), &lines); 27 StringToDouble(WideToUTF8(l10n_util::GetString(row_resource_id)), &lines);
28 int height = static_cast<int>(font.height() * lines); 28 int height = static_cast<int>(font.height() * lines);
29 DCHECK_GT(height, 0); 29 DCHECK_GT(height, 0);
30 return height; 30 return height;
31 } 31 }
32 32
33 gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id, 33 gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id,
34 int row_resource_id, 34 int row_resource_id,
35 const gfx::Font& font) { 35 const gfx::Font& font) {
36 return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font), 36 return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font),
37 GetLocalizedContentsHeightForFont(row_resource_id, font)); 37 GetLocalizedContentsHeightForFont(row_resource_id, font));
38 } 38 }
39 39
40 } // namespace gfx 40 } // namespace gfx
OLDNEW
« no previous file with comments | « app/gfx/font_unittest.cc ('k') | app/gfx/font_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698