| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 | 7 |
| 8 #include <cairo/cairo.h> | 8 #include <cairo/cairo.h> |
| 9 #include <pango/pango.h> | 9 #include <pango/pango.h> |
| 10 | 10 |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
| 15 #include "ui/gfx/gfx_export.h" | 15 #include "ui/gfx/gfx_export.h" |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 class FontList; | 19 class FontList; |
| 20 | 20 |
| 21 // Utility class to ensure that PangoFontDescription is freed. | 21 // Utility class to ensure that PangoFontDescription is freed. |
| 22 class ScopedPangoFontDescription { | 22 class ScopedPangoFontDescription { |
| 23 public: | 23 public: |
| 24 explicit ScopedPangoFontDescription(PangoFontDescription* description) | 24 explicit ScopedPangoFontDescription(PangoFontDescription* description) |
| 25 : description_(description) { | 25 : description_(description) { |
| 26 DCHECK(description); | 26 DCHECK(description); |
| 27 } | 27 } |
| 28 | 28 |
| 29 explicit ScopedPangoFontDescription(const std::string& str) |
| 30 : description_(pango_font_description_from_string(str.c_str())) { |
| 31 DCHECK(description_); |
| 32 } |
| 33 |
| 29 ~ScopedPangoFontDescription() { | 34 ~ScopedPangoFontDescription() { |
| 30 pango_font_description_free(description_); | 35 pango_font_description_free(description_); |
| 31 } | 36 } |
| 32 | 37 |
| 33 PangoFontDescription* get() { return description_; } | 38 PangoFontDescription* get() { return description_; } |
| 34 | 39 |
| 35 private: | 40 private: |
| 36 PangoFontDescription* description_; | 41 PangoFontDescription* description_; |
| 37 | 42 |
| 38 DISALLOW_COPY_AND_ASSIGN(ScopedPangoFontDescription); | 43 DISALLOW_COPY_AND_ASSIGN(ScopedPangoFontDescription); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 55 int GetPangoFontSizeInPixels(PangoFontDescription* pango_font); | 60 int GetPangoFontSizeInPixels(PangoFontDescription* pango_font); |
| 56 | 61 |
| 57 // Retrieves the Pango metrics for a Pango font description. Caches the metrics | 62 // 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 | 63 // and never frees them. The metrics objects are relatively small and very |
| 59 // expensive to look up. | 64 // expensive to look up. |
| 60 PangoFontMetrics* GetPangoFontMetrics(PangoFontDescription* desc); | 65 PangoFontMetrics* GetPangoFontMetrics(PangoFontDescription* desc); |
| 61 | 66 |
| 62 } // namespace gfx | 67 } // namespace gfx |
| 63 | 68 |
| 64 #endif // UI_GFX_PANGO_UTIL_H_ | 69 #endif // UI_GFX_PANGO_UTIL_H_ |
| OLD | NEW |