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

Unified Diff: ui/gfx/pango_util.cc

Issue 10406014: Add a ScopedPangoFontDescription helper class and use it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « ui/gfx/pango_util.h ('k') | ui/gfx/platform_font_pango.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/pango_util.cc
===================================================================
--- ui/gfx/pango_util.cc (revision 137485)
+++ ui/gfx/pango_util.cc (working copy)
@@ -8,6 +8,7 @@
#include <fontconfig/fontconfig.h>
#include <pango/pango.h>
#include <pango/pangocairo.h>
+#include <string>
#include <algorithm>
#include <map>
@@ -19,6 +20,7 @@
#include "ui/gfx/font.h"
#include "ui/gfx/platform_font_pango.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/skia_util.h"
#if defined(TOOLKIT_GTK)
#include <gdk/gdk.h>
@@ -29,8 +31,6 @@
#include "ui/base/ui_base_switches.h"
#endif
-#include "ui/gfx/skia_util.h"
-
namespace {
// Marker for accelerators in the text.
@@ -352,9 +352,8 @@
int flags) {
SetupPangoLayoutWithoutFont(layout, text, width, text_direction, flags);
- PangoFontDescription* desc = font.GetNativeFont();
- pango_layout_set_font_description(layout, desc);
- pango_font_description_free(desc);
+ ScopedPangoFontDescription desc(font.GetNativeFont());
+ pango_layout_set_font_description(layout, desc.get());
}
void SetupPangoLayoutWithFontDescription(
@@ -366,10 +365,9 @@
int flags) {
SetupPangoLayoutWithoutFont(layout, text, width, text_direction, flags);
- PangoFontDescription* desc = pango_font_description_from_string(
- font_description.c_str());
- pango_layout_set_font_description(layout, desc);
- pango_font_description_free(desc);
+ ScopedPangoFontDescription desc(
+ pango_font_description_from_string(font_description.c_str()));
+ pango_layout_set_font_description(layout, desc.get());
}
void AdjustTextRectBasedOnLayout(PangoLayout* layout,
« no previous file with comments | « ui/gfx/pango_util.h ('k') | ui/gfx/platform_font_pango.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698