OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_PANGO_UTIL_H_ | 5 #ifndef UI_GFX_PANGO_UTIL_H_ |
6 #define UI_GFX_PANGO_UTIL_H_ | 6 #define UI_GFX_PANGO_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <cairo/cairo.h> |
9 #include <pango/pango.h> | 10 #include <pango/pango.h> |
| 11 |
10 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
11 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "ui/base/ui_export.h" |
| 15 #include "third_party/skia/include/core/SkColor.h" |
12 | 16 |
13 // TODO(xji): move other pango related functions from gtk_util to here. | 17 // TODO(xji): move other pango related functions from gtk_util to here. |
14 | 18 |
15 namespace gfx { | 19 namespace gfx { |
16 | 20 |
17 class Font; | 21 class Font; |
| 22 class PlatformFontPango; |
| 23 class Rect; |
| 24 |
| 25 // Uses Pango to draw text onto |cr|. This is the public method for d |
| 26 void UI_EXPORT DrawTextOntoCairoSurface(cairo_t* cr, |
| 27 const string16& text, |
| 28 const gfx::Font& font, |
| 29 const gfx::Rect& bounds, |
| 30 const gfx::Rect& clip, |
| 31 const SkColor& text_color, |
| 32 int flags); |
| 33 |
| 34 // ---------------------------------------------------------------------------- |
| 35 // All other methods in this file are only to be used within the ui/ directory. |
| 36 // They are shared with internal skia interfaces. |
| 37 // ---------------------------------------------------------------------------- |
18 | 38 |
19 // Setup pango layout |layout|, including set layout text as |text|, font | 39 // Setup pango layout |layout|, including set layout text as |text|, font |
20 // description based on |font|, width as |width| in PANGO_SCALE for RTL lcoale, | 40 // description based on |font|, width as |width| in PANGO_SCALE for RTL lcoale, |
21 // and set up whether auto-detect directionality, alignment, ellipsis, word | 41 // and set up whether auto-detect directionality, alignment, ellipsis, word |
22 // wrapping, resolution etc. | 42 // wrapping, resolution etc. |
23 void SetupPangoLayout(PangoLayout* layout, | 43 void SetupPangoLayout(PangoLayout* layout, |
24 const string16& text, | 44 const string16& text, |
25 const gfx::Font& font, | 45 const gfx::Font& font, |
26 int width, | 46 int width, |
27 base::i18n::TextDirection text_direction, | 47 base::i18n::TextDirection text_direction, |
28 int flags); | 48 int flags); |
| 49 |
| 50 // Get Pango's calculated size of |layout| and modify |text_rect| within |
| 51 // |bounds|. |
| 52 void AdjustTextRectBasedOnLayout(PangoLayout* layout, |
| 53 const gfx::Rect& bounds, |
| 54 int flags, |
| 55 gfx::Rect* text_rect); |
| 56 |
| 57 // Draws the |layout| (pango tuple of font, actual text, etc) onto |cr| using |
| 58 // |text_color| as the cairo pattern. |
| 59 void DrawPangoLayout(cairo_t* cr, |
| 60 PangoLayout* layout, |
| 61 const Font& font, |
| 62 const gfx::Rect& bounds, |
| 63 const gfx::Rect& text_rect, |
| 64 const SkColor& text_color, |
| 65 base::i18n::TextDirection text_direction, |
| 66 int flags); |
| 67 |
| 68 // Draw an underline under the text using |cr|, which must already be |
| 69 // initialized with the correct source. |extra_edge_width| is added to the |
| 70 // outer edge of the line. |
| 71 void DrawPangoTextUnderline(cairo_t* cr, |
| 72 gfx::PlatformFontPango* platform_font, |
| 73 double extra_edge_width, |
| 74 const Rect& text_rect); |
| 75 |
29 } // namespace gfx | 76 } // namespace gfx |
30 | 77 |
31 #endif // UI_GFX_PANGO_UTIL_H_ | 78 #endif // UI_GFX_PANGO_UTIL_H_ |
OLD | NEW |