Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / base / l10n / l10n_font_util.cc
blob5e9f4da195fd49d97ae33f9d3920d31192510a97
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 "ui/base/l10n/l10n_util.h"
10 #include "ui/gfx/font.h"
12 namespace ui {
14 int GetLocalizedContentsWidthForFont(int col_resource_id,
15 const gfx::Font& font) {
16 int chars = 0;
17 base::StringToInt(l10n_util::GetStringUTF8(col_resource_id), &chars);
18 int width = font.GetExpectedTextWidth(chars);
19 DCHECK_GT(width, 0);
20 return width;
23 int GetLocalizedContentsHeightForFont(int row_resource_id,
24 const gfx::Font& font) {
25 int lines = 0;
26 base::StringToInt(l10n_util::GetStringUTF8(row_resource_id), &lines);
27 int height = font.GetHeight() * lines;
28 DCHECK_GT(height, 0);
29 return height;
32 gfx::Size GetLocalizedContentsSizeForFont(int col_resource_id,
33 int row_resource_id,
34 const gfx::Font& font) {
35 return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font),
36 GetLocalizedContentsHeightForFont(row_resource_id, font));
39 } // namespace ui