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

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

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 years, 9 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
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.cc ('k') | ui/gfx/icc_profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/font_list.h" 5 #include "ui/gfx/font_list.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "third_party/skia/include/core/SkTypeface.h" 11 #include "third_party/skia/include/core/SkTypeface.h"
12 #include "third_party/skia/include/ports/SkFontMgr.h" 12 #include "third_party/skia/include/ports/SkFontMgr.h"
13 #include "ui/gfx/font_list_impl.h" 13 #include "ui/gfx/font_list_impl.h"
14 14
15 namespace { 15 namespace {
16 16
17 // Font description of the default font set. 17 // Font description of the default font set.
18 base::LazyInstance<std::string>::Leaky g_default_font_description = 18 base::LazyInstance<std::string>::Leaky g_default_font_description =
19 LAZY_INSTANCE_INITIALIZER; 19 LAZY_INSTANCE_INITIALIZER;
20 20
21 // The default instance of gfx::FontListImpl. 21 // The default instance of gfx::FontListImpl.
22 base::LazyInstance<scoped_refptr<gfx::FontListImpl> >::Leaky g_default_impl = 22 base::LazyInstance<scoped_refptr<gfx::FontListImpl>>::Leaky g_default_impl =
23 LAZY_INSTANCE_INITIALIZER; 23 LAZY_INSTANCE_INITIALIZER;
24 bool g_default_impl_initialized = false; 24 bool g_default_impl_initialized = false;
25 25
26 bool IsFontFamilyAvailable(const std::string& family, SkFontMgr* fontManager) { 26 bool IsFontFamilyAvailable(const std::string& family, SkFontMgr* fontManager) {
27 #if defined(OS_LINUX) 27 #if defined(OS_LINUX)
28 sk_sp<SkTypeface> typeface( 28 sk_sp<SkTypeface> typeface(
29 fontManager->legacyCreateTypeface(family.c_str(), SkFontStyle())); 29 fontManager->legacyCreateTypeface(family.c_str(), SkFontStyle()));
30 return typeface; 30 return typeface;
31 #else 31 #else
32 sk_sp<SkFontStyleSet> set(fontManager->matchFamily(family.c_str())); 32 sk_sp<SkFontStyleSet> set(fontManager->matchFamily(family.c_str()));
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return families[0]; 246 return families[0];
247 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); 247 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
248 for (const auto& family : families) { 248 for (const auto& family : families) {
249 if (IsFontFamilyAvailable(family, fm.get())) 249 if (IsFontFamilyAvailable(family, fm.get()))
250 return family; 250 return family;
251 } 251 }
252 return families[0]; 252 return families[0];
253 } 253 }
254 254
255 } // namespace gfx 255 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.cc ('k') | ui/gfx/icc_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698