diff options
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/font.cc | 4 | ||||
-rw-r--r-- | gfx/font.h | 3 | ||||
-rw-r--r-- | gfx/font_unittest.cc | 14 |
3 files changed, 13 insertions, 8 deletions
diff --git a/gfx/font.cc b/gfx/font.cc index 1c3400b..6897022 100644 --- a/gfx/font.cc +++ b/gfx/font.cc @@ -58,8 +58,8 @@ int Font::GetAverageCharacterWidth() const { return platform_font_->GetAverageCharacterWidth(); } -int Font::GetStringWidth(const std::wstring& text) const { - return platform_font_->GetStringWidth(WideToUTF16Hack(text)); +int Font::GetStringWidth(const string16& text) const { + return platform_font_->GetStringWidth(text); } int Font::GetExpectedTextWidth(int length) const { @@ -9,6 +9,7 @@ #include <string> #include "base/ref_counted.h" +#include "base/string16.h" #include "gfx/native_widget_types.h" namespace gfx { @@ -73,7 +74,7 @@ class Font { // Returns the number of horizontal pixels needed to display the specified // string. - int GetStringWidth(const std::wstring& text) const; + int GetStringWidth(const string16& text) const; // Returns the expected number of horizontal pixels needed to display the // specified length of characters. Call GetStringWidth() to retrieve the diff --git a/gfx/font_unittest.cc b/gfx/font_unittest.cc index 1cf1b11..3f26507 100644 --- a/gfx/font_unittest.cc +++ b/gfx/font_unittest.cc @@ -1,9 +1,10 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "gfx/font.h" +#include "base/utf_string_conversions.h" #if defined(OS_WIN) #include "gfx/platform_font_win.h" #endif // defined(OS_WIN) @@ -82,10 +83,13 @@ TEST_F(FontTest, AvgWidths) { TEST_F(FontTest, Widths) { Font cf(L"Arial", 16); - ASSERT_EQ(cf.GetStringWidth(L""), 0); - ASSERT_GT(cf.GetStringWidth(L"a"), cf.GetStringWidth(L"")); - ASSERT_GT(cf.GetStringWidth(L"ab"), cf.GetStringWidth(L"a")); - ASSERT_GT(cf.GetStringWidth(L"abc"), cf.GetStringWidth(L"ab")); + ASSERT_EQ(cf.GetStringWidth(ASCIIToUTF16("")), 0); + ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("a")), + cf.GetStringWidth(ASCIIToUTF16(""))); + ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("ab")), + cf.GetStringWidth(ASCIIToUTF16("a"))); + ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("abc")), + cf.GetStringWidth(ASCIIToUTF16("ab"))); } #if defined(OS_WIN) |