Mac: More robust "window under location" for interactive_ui_tests
[chromium-blink-merge.git] / ui / gfx / pango_util.h
blobe194b0a4688877dc534727f1ce54e52584f6eb9e
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"
17 namespace gfx {
19 class FontList;
21 // Utility class to ensure that PangoFontDescription is freed.
22 class ScopedPangoFontDescription {
23 public:
24 explicit ScopedPangoFontDescription(PangoFontDescription* description)
25 : description_(description) {
26 DCHECK(description);
29 explicit ScopedPangoFontDescription(const std::string& str)
30 : description_(pango_font_description_from_string(str.c_str())) {
31 DCHECK(description_);
34 ~ScopedPangoFontDescription() {
35 pango_font_description_free(description_);
38 PangoFontDescription* get() { return description_; }
40 private:
41 PangoFontDescription* description_;
43 DISALLOW_COPY_AND_ASSIGN(ScopedPangoFontDescription);
46 // ----------------------------------------------------------------------------
47 // All other methods in this file are only to be used within the ui/ directory.
48 // They are shared with internal skia interfaces.
49 // ----------------------------------------------------------------------------
51 // Configures |layout| for the passed-in parameters.
52 void SetUpPangoLayout(
53 PangoLayout* layout,
54 const base::string16& text,
55 const FontList& font_list,
56 base::i18n::TextDirection text_direction,
57 int flags);
59 // Returns the size in pixels for the specified |pango_font|.
60 int GetPangoFontSizeInPixels(PangoFontDescription* pango_font);
62 // Retrieves the Pango metrics for a Pango font description. Caches the metrics
63 // and never frees them. The metrics objects are relatively small and very
64 // expensive to look up.
65 PangoFontMetrics* GetPangoFontMetrics(PangoFontDescription* desc);
67 } // namespace gfx
69 #endif // UI_GFX_PANGO_UTIL_H_