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. 4 5 #include "chrome/browser/ui/webui/options/font_settings_utils.h" 6 7 #include <set> 8 #include <string> 9 10 #include <pango/pango.h> 11 #include <pango/pangocairo.h> 12 13 #include "base/values.h" 14 15 ListValue* FontSettingsUtilities::GetFontsList() { 16 ListValue* font_list = new ListValue; 17 18 PangoFontMap* font_map = ::pango_cairo_font_map_get_default(); 19 PangoFontFamily** families = NULL; 20 int num_families = 0; 21 ::pango_font_map_list_families(font_map, &families, &num_families); 22 23 std::set<std::string> sorted_families; 24 for (int i = 0; i < num_families; i++) { 25 sorted_families.insert(::pango_font_family_get_name(families[i])); 26 } 27 g_free(families); 28 29 for (std::set<std::string>::const_iterator iter = sorted_families.begin(); 30 iter != sorted_families.end(); ++iter) { 31 ListValue* font_item = new ListValue(); 32 font_item->Append(Value::CreateStringValue(*iter)); 33 font_item->Append(Value::CreateStringValue(*iter)); // localized name. 34 // TODO(yusukes): Support localized family names. 35 font_list->Append(font_item); 36 } 37 38 return font_list; 39 } 40 41 void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) { 42 // nothing to do for GTK. 43 } 44