OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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. |
| 4 |
| 5 #include "ui/gfx/canvas.h" |
| 6 |
| 7 #import <UIKit/UIKit.h> |
| 8 |
| 9 #include <algorithm> |
| 10 #include <cmath> |
| 11 |
| 12 #include "base/logging.h" |
| 13 #include "base/strings/sys_string_conversions.h" |
| 14 #include "ui/gfx/font_list.h" |
| 15 |
| 16 namespace gfx { |
| 17 |
| 18 // static |
| 19 void Canvas::SizeStringInt(const base::string16& text, |
| 20 const gfx::FontList& font_list, |
| 21 int* width, |
| 22 int* height, |
| 23 int line_height, |
| 24 int flags) { |
| 25 DLOG_IF(WARNING, line_height != 0) << "Line height not implemented."; |
| 26 DLOG_IF(WARNING, flags & Canvas::MULTI_LINE) << "Multi-line not implemented."; |
| 27 |
| 28 NSString* ns_text = base::SysUTF16ToNSString(text); |
| 29 CGSize size = [ns_text |
| 30 sizeWithFont:font_list.GetPrimaryFont().GetNativeFont()]; |
| 31 *width = std::ceil(size.width); |
| 32 *height = std::max(static_cast<int>(std::ceil(size.height)), |
| 33 font_list.GetHeight()); |
| 34 } |
| 35 |
| 36 } // namespace gfx |
OLD | NEW |