1 /* 2 * Copyright (C) 2015 The Android Open Source Project 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 MINIKIN_TEST_MINIKIN_FONT_FOR_TEST_H 18 #define MINIKIN_TEST_MINIKIN_FONT_FOR_TEST_H 19 20 #include <minikin/MinikinFont.h> 21 22 class SkTypeface; 23 24 namespace minikin { 25 26 class MinikinFontForTest : public MinikinFont { 27 public: 28 MinikinFontForTest(const std::string& font_path, 29 int index, 30 const std::vector<FontVariation>& variations); MinikinFontForTest(const std::string & font_path,int index)31 MinikinFontForTest(const std::string& font_path, int index) 32 : MinikinFontForTest(font_path, index, std::vector<FontVariation>()) {} MinikinFontForTest(const std::string & font_path)33 MinikinFontForTest(const std::string& font_path) 34 : MinikinFontForTest(font_path, 0) {} 35 virtual ~MinikinFontForTest(); 36 37 // MinikinFont overrides. 38 float GetHorizontalAdvance(uint32_t glyph_id, 39 const MinikinPaint& paint) const; 40 void GetBounds(MinikinRect* bounds, 41 uint32_t glyph_id, 42 const MinikinPaint& paint) const; 43 fontPath()44 const std::string& fontPath() const { return mFontPath; } 45 GetFontData()46 const void* GetFontData() const { return mFontData; } GetFontSize()47 size_t GetFontSize() const { return mFontSize; } GetFontIndex()48 int GetFontIndex() const { return mFontIndex; } GetAxes()49 const std::vector<minikin::FontVariation>& GetAxes() const { 50 return mVariations; 51 } 52 std::shared_ptr<MinikinFont> createFontWithVariation( 53 const std::vector<FontVariation>& variations) const; 54 55 private: 56 MinikinFontForTest() = delete; 57 MinikinFontForTest(const MinikinFontForTest&) = delete; 58 MinikinFontForTest& operator=(MinikinFontForTest&) = delete; 59 60 const std::string mFontPath; 61 const std::vector<FontVariation> mVariations; 62 const int mFontIndex; 63 void* mFontData; 64 size_t mFontSize; 65 }; 66 67 } // namespace minikin 68 69 #endif // MINIKIN_TEST_MINIKIN_FONT_FOR_TEST_H 70