Print Preview: Refactoring print/cancel button and print summary.
[chromium-blink-merge.git] / content / common / font_list_gtk.cc
blob0742bb32b0a3e8105ea7f04ce17aa464a37ebfab
1 // Copyright (c) 2011 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 #include "content/common/font_list.h"
7 #include <pango/pango.h>
8 #include <pango/pangocairo.h>
10 #include <set>
11 #include <string>
13 #include "base/values.h"
15 namespace content {
17 ListValue* GetFontList_SlowBlocking() {
18 ListValue* font_list = new ListValue;
20 PangoFontMap* font_map = ::pango_cairo_font_map_get_default();
21 PangoFontFamily** families = NULL;
22 int num_families = 0;
23 ::pango_font_map_list_families(font_map, &families, &num_families);
25 std::set<std::string> sorted_families;
26 for (int i = 0; i < num_families; i++) {
27 sorted_families.insert(::pango_font_family_get_name(families[i]));
29 g_free(families);
31 for (std::set<std::string>::const_iterator iter = sorted_families.begin();
32 iter != sorted_families.end(); ++iter) {
33 ListValue* font_item = new ListValue();
34 font_item->Append(Value::CreateStringValue(*iter));
35 font_item->Append(Value::CreateStringValue(*iter)); // localized name.
36 // TODO(yusukes): Support localized family names.
37 font_list->Append(font_item);
40 return font_list;
43 } // namespace content