c++11: Add discussion thread links, ban things that don't work with MSVS.
[chromium-blink-merge.git] / ui / base / l10n / l10n_font_util.cc
blobbd28add5e83e552b434d7bd4c1019b270251ed7d
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/base/l10n/l10n_font_util.h"
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/gfx/font.h"
13 namespace ui {
15 int GetLocalizedContentsWidthForFont(int col_resource_id,
16 const gfx::Font& font) {
17 double chars = 0;
18 base::StringToDouble(l10n_util::GetStringUTF8(col_resource_id), &chars);
19 int width = font.GetExpectedTextWidth(static_cast<int>(chars));
20 DCHECK_GT(width, 0);
21 return width;
24 int GetLocalizedContentsHeightForFont(int row_resource_id,
25 const gfx::Font& font) {
26 double lines = 0;
27 base::StringToDouble(l10n_util::GetStringUTF8(row_resource_id), &lines);
28 int height = static_cast<int>(font.GetHeight() * lines);
29 DCHECK_GT(height, 0);
30 return height;
33 gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id,
34 int row_resource_id,
35 const gfx::Font& font) {
36 return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font),
37 GetLocalizedContentsHeightForFont(row_resource_id, font));
40 } // namespace ui