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

Side by Side Diff: content/common/font_list_pango.cc

Issue 2278143002: Filter font list, use Fontconfig and build on Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments by avi@ addressed Created 4 years, 3 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698