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

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: fix tests; add placeholder impl for Mac Created 6 years, 6 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 FcPattern* pattern = FcPatternCreate();
14 FcValue family;
15 family.type = FcTypeString;
16 family.u.s = reinterpret_cast<const unsigned char*>(font_family.c_str());
msw 2014/06/30 17:35:53 Maybe use FcChar8* to match the FC types like plat
ckocagil 2014/07/04 15:30:15 Done.
17 FcPatternAdd(pattern, FC_FAMILY, family, FcFalse);
18
19 FcConfigSubstitute(NULL, pattern, FcMatchPattern);
msw 2014/06/30 17:35:53 Check the return value here? (I guess font_render_
ckocagil 2014/07/04 15:30:15 Let's do it here anyway, done.
20 FcDefaultSubstitute(pattern);
21 FcResult result;
22 FcFontSet* fonts = FcFontSort(NULL, pattern, FcTrue, NULL, &result);
23
24 if (fonts) {
25 for (int i = 0; i < fonts->nfont; ++i) {
26 char* name = NULL;
27 FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0,
28 reinterpret_cast<unsigned char**>(&name));
29 if (fallback_fonts.empty() || fallback_fonts.back() != name)
msw 2014/06/30 17:35:53 Do we expect there to be adjacent duplicate entrie
ckocagil 2014/07/04 15:30:15 Yes. Currently we only take the family name into a
msw 2014/07/07 22:52:45 That seems worth explaining in a short comment her
ckocagil 2014/07/12 11:47:54 Done.
30 fallback_fonts.push_back(std::string(name));
31 }
32
33 FcFontSetDestroy(fonts);
34 }
35
36 FcPatternDestroy(pattern);
37
38 if (fallback_fonts.empty())
39 fallback_fonts.push_back(font_family);
40
41 return fallback_fonts;
42 }
43
44 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_fallback.h ('k') | ui/gfx/font_fallback_mac.cc » ('j') | ui/gfx/font_fallback_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698