Flutter Engine
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 
17 #include "txt/test_font_manager.h"
18 #include "flutter/fml/logging.h"
19 
20 namespace 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 
30 SkFontStyleSet* TestFontManager::onMatchFamily(const char family_name[]) const {
31  // Find the requested name in the list, if not found, default to the first
32  // font family in the test font family list.
33  std::string requested_name(family_name);
34  std::string sanitized_name = test_font_family_names_[0];
35  for (const std::string& test_family : test_font_family_names_) {
36  if (requested_name == test_family) {
37  sanitized_name = test_family;
38  }
39  }
40  return AssetFontManager::onMatchFamily(sanitized_name.c_str());
41 }
42 
43 } // namespace txt
TestFontManager(std::unique_ptr< FontAssetProvider > font_provider, std::vector< std::string > test_font_family_names)
~TestFontManager() override
Definition: ref_ptr.h:252
SkFontStyleSet * onMatchFamily(const char familyName[]) const override