Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
test_font_manager.cc
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
18#include "flutter/fml/logging.h"
19
20namespace txt {
21
23 std::unique_ptr<FontAssetProvider> font_provider,
24 std::vector<std::string> test_font_family_names)
25 : AssetFontManager(std::move(font_provider)),
26 test_font_family_names_(test_font_family_names) {}
27
29
31 const char family_name[]) const {
32 // Find the requested name in the list, if not found, default to the first
33 // font family in the test font family list.
34 std::string requested_name(family_name);
35 std::string sanitized_name = test_font_family_names_[0];
36 for (const std::string& test_family : test_font_family_names_) {
37 if (requested_name == test_family) {
38 sanitized_name = test_family;
39 }
40 }
41 return AssetFontManager::onMatchFamily(sanitized_name.c_str());
42}
43
44} // namespace txt
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
~TestFontManager() override
sk_sp< SkFontStyleSet > onMatchFamily(const char family_name[]) const override
TestFontManager(std::unique_ptr< FontAssetProvider > font_provider, std::vector< std::string > test_font_family_names)
Definition ref_ptr.h:256