Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: ui/gfx/canvas_ios.mm

Issue 22835002: Supports gfx::FontList in gfx::Canvas and ui::ElideText family. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adds canvas_ios.mm and removes canvas_android.cc. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/canvas_ios.mm
diff --git a/ui/gfx/canvas_ios.mm b/ui/gfx/canvas_ios.mm
new file mode 100644
index 0000000000000000000000000000000000000000..a1f45d291e90c6857416e4f88c1660562feef38d
--- /dev/null
+++ b/ui/gfx/canvas_ios.mm
@@ -0,0 +1,36 @@
+// Copyright (c) 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/canvas.h"
+
+#import <UIKit/UIKit.h>
+
+#include <algorithm>
+#include <cmath>
+
+#include "base/logging.h"
+#include "base/strings/sys_string_conversions.h"
+#include "ui/gfx/font_list.h"
+
+namespace gfx {
+
+// static
+void Canvas::SizeStringInt(const base::string16& text,
+ const gfx::FontList& font_list,
+ int* width,
+ int* height,
+ int line_height,
+ int flags) {
+ DLOG_IF(WARNING, line_height != 0) << "Line height not implemented.";
+ DLOG_IF(WARNING, flags & Canvas::MULTI_LINE) << "Multi-line not implemented.";
+
+ NSString* ns_text = base::SysUTF16ToNSString(text);
+ CGSize size = [ns_text
+ sizeWithFont:font_list.GetPrimaryFont().GetNativeFont()];
+ *width = std::ceil(size.width);
+ *height = std::max(static_cast<int>(std::ceil(size.height)),
+ font_list.GetHeight());
+}
+
+} // namespace gfx
« ui/gfx/canvas.cc ('K') | « ui/gfx/canvas_android.cc ('k') | ui/gfx/canvas_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698