Flutter Engine
 
Loading...
Searching...
No Matches
test_font_manager.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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
7
8namespace txt {
9
11 std::unique_ptr<FontAssetProvider> font_provider,
12 std::vector<std::string> test_font_family_names)
13 : AssetFontManager(std::move(font_provider)),
14 test_font_family_names_(std::move(test_font_family_names)) {}
15
17
18sk_sp<SkFontStyleSet> TestFontManager::onMatchFamily(
19 const char family_name[]) const {
20 // Find the requested name in the list, if not found, default to the first
21 // font family in the test font family list.
22 std::string requested_name(family_name);
23 std::string sanitized_name = test_font_family_names_[0];
24 for (const std::string& test_family : test_font_family_names_) {
25 if (requested_name == test_family) {
26 sanitized_name = test_family;
27 }
28 }
29 return AssetFontManager::onMatchFamily(sanitized_name.c_str());
30}
31
32} // namespace txt
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
~TestFontManager() override
TestFontManager(std::unique_ptr< FontAssetProvider > font_provider, std::vector< std::string > test_font_family_names)
Definition ref_ptr.h:261