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

Side by Side Diff: ui/gfx/font_fallback_linux.cc

Issue 331713003: RenderTextHarfBuzz: Implement font fallback for Win and Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "ui/gfx/font_fallback.h"
6
7 #include <fontconfig/fontconfig.h>
8
9 namespace gfx {
10
11 std::vector<std::string> GetFallbackFontFamilies(std::string font_family) {
12 std::vector<std::string> fallback_fonts;
13
14 FcPattern* pattern = FcPatternCreate();
15 FcValue family;
16 family.type = FcTypeString;
17 family.u.s = reinterpret_cast<const FcChar8*>(font_family.c_str());
18 FcPatternAdd(pattern, FC_FAMILY, family, FcFalse);
19 if (FcConfigSubstitute(NULL, pattern, FcMatchPattern) == FcTrue) {
20 FcDefaultSubstitute(pattern);
21 FcResult result;
22 FcFontSet* fonts = FcFontSort(NULL, pattern, FcTrue, NULL, &result);
23 if (fonts) {
24 for (int i = 0; i < fonts->nfont; ++i) {
25 char* name = NULL;
26 FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0,
27 reinterpret_cast<FcChar8**>(&name));
28 if (fallback_fonts.empty() || fallback_fonts.back() != name)
29 fallback_fonts.push_back(std::string(name));
30 }
31 FcFontSetDestroy(fonts);
32 }
33 }
34 FcPatternDestroy(pattern);
35
36 if (fallback_fonts.empty())
37 fallback_fonts.push_back(font_family);
38
39 return fallback_fonts;
40 }
41
42 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698