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 #ifndef TXT_TEST_FONT_MANAGER_H_ 18 #define TXT_TEST_FONT_MANAGER_H_ 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "flutter/fml/macros.h" 25 #include "third_party/skia/include/core/SkFontMgr.h" 26 #include "txt/asset_font_manager.h" 27 #include "txt/font_asset_provider.h" 28 29 namespace txt { 30 31 // A font manager intended for tests that matches all requested fonts using 32 // one family. 33 class TestFontManager : public AssetFontManager { 34 public: 35 TestFontManager(std::unique_ptr<FontAssetProvider> font_provider, 36 std::vector<std::string> test_font_family_names); 37 38 ~TestFontManager() override; 39 40 private: 41 std::vector<std::string> test_font_family_names_; 42 43 SkFontStyleSet* onMatchFamily(const char family_name[]) const override; 44 45 FML_DISALLOW_COPY_AND_ASSIGN(TestFontManager); 46 }; 47 48 } // namespace txt 49 50 #endif // TXT_TEST_FONT_MANAGER_H_ 51