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

Unified Diff: ui/gfx/canvas.h

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.h
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index 8baa45c11e32f7a9b8a167bf5dd9268b7169beb5..09be7a65a2a49ae1eb1f7c5547aad5e6c747dd43 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -20,6 +20,7 @@ namespace gfx {
class Rect;
class Font;
+class FontList;
class Point;
class Size;
class Transform;
@@ -121,19 +122,28 @@ class UI_EXPORT Canvas {
ui::ScaleFactor scale_factor,
bool is_opaque);
- // Compute the size required to draw some text with the provided font.
+ // Compute the size required to draw some text with the provided fonts.
// Attempts to fit the text with the provided width and height. Increases
// height and then width as needed to make the text fit. This method
// supports multiple lines. On Skia only a line_height can be specified and
// specifying a 0 value for it will cause the default height to be used.
static void SizeStringInt(const base::string16& text,
+ const gfx::FontList& font_list,
+ int* width, int* height,
Alexei Svitkine (slow) 2013/08/12 18:16:21 Nit: can you fix this to be 1 param per line, per
Yuki 2013/08/13 09:32:13 Done.
+ int line_height,
+ int flags);
+ // Obsolete version. Use the above version which takes gfx::FontList.
+ static void SizeStringInt(const base::string16& text,
const gfx::Font& font,
int* width, int* height,
int line_height,
int flags);
// Returns the number of horizontal pixels needed to display the specified
- // |text| with |font|.
+ // |text| with |font_list|.
+ static int GetStringWidth(const base::string16& text,
+ const gfx::FontList& font_list);
+ // Obsolete version. Use the above version which takes gfx::FontList.
static int GetStringWidth(const base::string16& text, const gfx::Font& font);
// Returns the default text alignment to be used when drawing text on a
@@ -146,7 +156,7 @@ class UI_EXPORT Canvas {
static int DefaultCanvasTextAlignment();
// Draws text with a 1-pixel halo around it of the given color.
- // On Windows, it allows ClearType to be drawn to an otherwise transparenct
+ // On Windows, it allows ClearType to be drawn to an otherwise transparent
// bitmap for drag images. Drag images have only 1-bit of transparency, so
// we don't do any fancy blurring.
// On Linux, text with halo is created by stroking it with 2px |halo_color|
@@ -155,6 +165,13 @@ class UI_EXPORT Canvas {
// TODO(dhollowa): Skia-native implementation is underway. Cut over to
// that when ready. http::/crbug.com/109946
void DrawStringWithHalo(const base::string16& text,
+ const gfx::FontList& font_list,
+ SkColor text_color,
+ SkColor halo_color,
+ const Rect& display_rect,
+ int flags);
+ // Obsolete version. Use the above version which takes gfx::FontList.
+ void DrawStringWithHalo(const base::string16& text,
const gfx::Font& font,
SkColor text_color,
SkColor halo_color,
@@ -302,9 +319,14 @@ class UI_EXPORT Canvas {
const SkPath& path,
const SkPaint& paint);
- // Draws text with the specified color, font and location. The text is
+ // Draws text with the specified color, fonts and location. The text is
// aligned to the left, vertically centered, clipped to the region. If the
// text is too big, it is truncated and '...' is added to the end.
+ void DrawString(const base::string16& text,
+ const gfx::FontList& font_list,
+ SkColor color,
+ const gfx::Rect& display_rect);
+ // Obsolete versions. Use the above versions which take gfx::FontList.
void DrawStringInt(const base::string16& text,
const gfx::Font& font,
SkColor color,
@@ -314,9 +336,15 @@ class UI_EXPORT Canvas {
SkColor color,
const gfx::Rect& display_rect);
- // Draws text with the specified color, font and location. The last argument
+ // Draws text with the specified color, fonts and location. The last argument
// specifies flags for how the text should be rendered. It can be one of
// TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT.
+ void DrawStringWithAligned(const base::string16& text,
Alexei Svitkine (slow) 2013/08/12 18:16:21 Flags can specify more than just alignment. How ab
Yuki 2013/08/13 09:32:13 Done.
+ const gfx::FontList& font_list,
+ SkColor color,
+ const gfx::Rect& display_rect,
+ int flags);
+ // Obsolete version. Use the above version which takes gfx::FontList.
void DrawStringInt(const base::string16& text,
const gfx::Font& font,
SkColor color,
@@ -327,6 +355,14 @@ class UI_EXPORT Canvas {
// Currently it's only implemented for canvas skia. Specifying a 0 line_height
// will cause the default height to be used.
void DrawStringWithShadows(const base::string16& text,
+ const gfx::FontList& font_list,
+ SkColor color,
+ const gfx::Rect& text_bounds,
+ int line_height,
+ int flags,
+ const ShadowValues& shadows);
+ // Obsolete version. Use the above version which takes gfx::FontList.
+ void DrawStringWithShadows(const base::string16& text,
const gfx::Font& font,
SkColor color,
const gfx::Rect& text_bounds,
@@ -369,6 +405,14 @@ class UI_EXPORT Canvas {
const base::string16& text,
TruncateFadeMode truncate_mode,
size_t desired_characters_to_truncate_from_head,
+ const gfx::FontList& font_list,
+ SkColor color,
+ const gfx::Rect& display_rect);
+ // Obsolete version. Use the above version which takes gfx::FontList.
+ void DrawFadeTruncatingString(
+ const base::string16& text,
+ TruncateFadeMode truncate_mode,
+ size_t desired_characters_to_truncate_from_head,
const gfx::Font& font,
SkColor color,
const gfx::Rect& display_rect);

Powered by Google App Engine
This is Rietveld 408576698