| OLD | NEW |
| (Empty) |
| 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 "content/common/font_list.h" | |
| 6 | |
| 7 #include <pango/pango.h> | |
| 8 #include <pango/pangocairo.h> | |
| 9 | |
| 10 #include <set> | |
| 11 #include <string> | |
| 12 #include <utility> | |
| 13 | |
| 14 #include "base/values.h" | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { | |
| 19 std::unique_ptr<base::ListValue> font_list(new base::ListValue); | |
| 20 | |
| 21 PangoFontMap* font_map = ::pango_cairo_font_map_get_default(); | |
| 22 PangoFontFamily** families = NULL; | |
| 23 int num_families = 0; | |
| 24 ::pango_font_map_list_families(font_map, &families, &num_families); | |
| 25 | |
| 26 std::set<std::string> sorted_families; | |
| 27 for (int i = 0; i < num_families; i++) { | |
| 28 sorted_families.insert(::pango_font_family_get_name(families[i])); | |
| 29 } | |
| 30 g_free(families); | |
| 31 | |
| 32 for (std::set<std::string>::const_iterator iter = sorted_families.begin(); | |
| 33 iter != sorted_families.end(); ++iter) { | |
| 34 std::unique_ptr<base::ListValue> font_item(new base::ListValue()); | |
| 35 font_item->AppendString(*iter); | |
| 36 font_item->AppendString(*iter); // localized name. | |
| 37 // TODO(yusukes): Support localized family names. | |
| 38 font_list->Append(std::move(font_item)); | |
| 39 } | |
| 40 | |
| 41 return font_list; | |
| 42 } | |
| 43 | |
| 44 } // namespace content | |
| OLD | NEW |