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

Unified Diff: ui/gfx/render_text_linux.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/platform_font_pango_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_linux.cc
===================================================================
--- ui/gfx/render_text_linux.cc (revision 137485)
+++ ui/gfx/render_text_linux.cc (working copy)
@@ -148,10 +148,8 @@
const int end = LayoutIndexToTextIndex(item->offset + item->length);
const ui::Range range(start, end);
- PangoFontDescription* native_font =
- pango_font_describe(item->analysis.font);
- spans.push_back(RenderText::FontSpan(Font(native_font), range));
- pango_font_description_free(native_font);
+ ScopedPangoFontDescription desc(pango_font_describe(item->analysis.font));
+ spans.push_back(RenderText::FontSpan(Font(desc.get()), range));
}
return spans;
@@ -341,14 +339,13 @@
// with the same Fonts (to avoid unnecessarily splitting up runs).
if (i->font_style != default_font_style) {
FontList derived_font_list = font_list().DeriveFontList(i->font_style);
- PangoFontDescription* desc = pango_font_description_from_string(
- derived_font_list.GetFontDescriptionString().c_str());
+ ScopedPangoFontDescription desc(pango_font_description_from_string(
+ derived_font_list.GetFontDescriptionString().c_str()));
- PangoAttribute* pango_attr = pango_attr_font_desc_new(desc);
+ PangoAttribute* pango_attr = pango_attr_font_desc_new(desc.get());
pango_attr->start_index = TextIndexToLayoutIndex(i->range.start());
pango_attr->end_index = TextIndexToLayoutIndex(i->range.end());
pango_attr_list_insert(attrs, pango_attr);
- pango_font_description_free(desc);
}
}
@@ -411,15 +408,13 @@
}
DCHECK_GE(style, 0);
- PangoFontDescription* native_font =
- pango_font_describe(run->item->analysis.font);
+ ScopedPangoFontDescription desc(
+ pango_font_describe(run->item->analysis.font));
const std::string family_name =
- pango_font_description_get_family(native_font);
- renderer.SetTextSize(GetPangoFontSizeInPixels(native_font));
+ pango_font_description_get_family(desc.get());
+ renderer.SetTextSize(GetPangoFontSizeInPixels(desc.get()));
- pango_font_description_free(native_font);
-
SkScalar glyph_x = x;
SkScalar start_x = x;
int start = 0;
« no previous file with comments | « ui/gfx/platform_font_pango_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698