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

Unified Diff: ui/gfx/canvas.cc

Issue 22835002: Supports gfx::FontList in gfx::Canvas and ui::ElideText family. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 2b0f5046cf0ced0cccf96b9274e1b8965af1e667..5c7b0dacfe6ca4fcb7a1b182612d1e93a89676f9 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -11,7 +11,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/gfx/canvas.h"
-#include "ui/gfx/font.h"
+#include "ui/gfx/font_list.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/skia_util.h"
@@ -87,6 +87,14 @@ void Canvas::RecreateBackingCanvas(const gfx::Size& size,
}
// static
+int Canvas::GetStringWidth(const base::string16& text,
+ const gfx::FontList& font_list) {
+ int width = 0, height = 0;
+ Canvas::SizeStringInt(text, font_list, &width, &height, 0, NO_ELLIPSIS);
+ return width;
+}
+
+// static
int Canvas::GetStringWidth(const base::string16& text, const gfx::Font& font) {
int width = 0, height = 0;
Canvas::SizeStringInt(text, font, &width, &height, 0, NO_ELLIPSIS);
@@ -409,6 +417,28 @@ void Canvas::DrawImageInPath(const gfx::ImageSkia& image,
canvas_->drawPath(path, p);
}
+void Canvas::DrawString(const base::string16& text,
+ const gfx::FontList& font_list,
+ SkColor color,
+ const gfx::Rect& display_rect) {
+ DrawStringWithAligned(text, font_list, color, display_rect,
+ DefaultCanvasTextAlignment());
+}
+
+void Canvas::DrawStringWithAligned(const base::string16& text,
+ const gfx::FontList& font_list,
+ SkColor color,
+ const gfx::Rect& display_rect,
+ int flags) {
+ DrawStringWithShadows(text,
+ font_list,
+ color,
+ display_rect,
+ 0,
+ flags,
+ ShadowValues());
+}
+
void Canvas::DrawStringInt(const base::string16& text,
const gfx::Font& font,
SkColor color,

Powered by Google App Engine
This is Rietveld 408576698