1 // Copyright (c) 2012 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.
5 #ifndef UI_GFX_PANGO_UTIL_H_
6 #define UI_GFX_PANGO_UTIL_H_
8 #include <cairo/cairo.h>
9 #include <pango/pango.h>
11 #include "base/i18n/rtl.h"
12 #include "base/logging.h"
13 #include "base/strings/string16.h"
14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/gfx_export.h"
21 // Utility class to ensure that PangoFontDescription is freed.
22 class ScopedPangoFontDescription
{
24 explicit ScopedPangoFontDescription(PangoFontDescription
* description
)
25 : description_(description
) {
29 ~ScopedPangoFontDescription() {
30 pango_font_description_free(description_
);
33 PangoFontDescription
* get() { return description_
; }
36 PangoFontDescription
* description_
;
38 DISALLOW_COPY_AND_ASSIGN(ScopedPangoFontDescription
);
41 // ----------------------------------------------------------------------------
42 // All other methods in this file are only to be used within the ui/ directory.
43 // They are shared with internal skia interfaces.
44 // ----------------------------------------------------------------------------
46 // Configures |layout| for the passed-in parameters.
47 void SetUpPangoLayout(
49 const base::string16
& text
,
50 const FontList
& font_list
,
51 base::i18n::TextDirection text_direction
,
54 // Returns the size in pixels for the specified |pango_font|.
55 int GetPangoFontSizeInPixels(PangoFontDescription
* pango_font
);
57 // Retrieves the Pango metrics for a Pango font description. Caches the metrics
58 // and never frees them. The metrics objects are relatively small and very
59 // expensive to look up.
60 PangoFontMetrics
* GetPangoFontMetrics(PangoFontDescription
* desc
);
64 #endif // UI_GFX_PANGO_UTIL_H_