commit | ad8d9d577af1a4cb79c7dbbf4b57b1156a6f0143 | [log] [tgz] |
---|---|---|
author | [email protected] <[email protected]@0039d316-1c4b-4281-b951-d872f2087c98> | Thu Aug 22 07:20:05 2013 |
committer | [email protected] <[email protected]@0039d316-1c4b-4281-b951-d872f2087c98> | Thu Aug 22 07:20:05 2013 |
tree | 4667e32b426f21c4c7d5c6364a94e2f0ce33da29 | |
parent | 103ff3515ea4c37d7924fca6fee61d83da8d2744 [diff] [blame] |
Supports gfx::FontList in gfx::Canvas and ui::ElideText family. This is a part of the plan to support gfx::FontList in views::Label. https://docs.google.com/a/chromium.org/document/d/1D_25fp9B8b9aZJORfAjDIFq61NWvUquZ5xmKH-VcC4k/edit BUG=265485 Review URL: https://chromiumcodereview.appspot.com/22835002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218926 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/gfx/text_utils_ios.mm b/ui/gfx/text_utils_ios.mm new file mode 100644 index 0000000..1841864 --- /dev/null +++ b/ui/gfx/text_utils_ios.mm
@@ -0,0 +1,22 @@ +// Copyright 2013 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 "ui/gfx/text_utils.h" + +#import <UIKit/UIKit.h> + +#include <cmath> + +#include "base/strings/sys_string_conversions.h" +#include "ui/gfx/font_list.h" + +namespace gfx { + +int GetStringWidth(const base::string16& text, const FontList& font_list) { + NSString* ns_text = base::SysUTF16ToNSString(text); + NativeFont native_font = font_list.GetPrimaryFont().GetNativeFont(); + return std::ceil([ns_text sizeWithFont:native_font].width); +} + +} // namespace gfx