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, int index, 29 const std::vector<FontVariation>& variations); MinikinFontForTest(const std::string & font_path,int index)30 MinikinFontForTest(const std::string& font_path, int index) 31 : MinikinFontForTest(font_path, index, std::vector<FontVariation>()) {} MinikinFontForTest(const std::string & font_path)32 MinikinFontForTest(const std::string& font_path) : MinikinFontForTest(font_path, 0) {} 33 virtual ~MinikinFontForTest(); 34 35 // MinikinFont overrides. 36 float GetHorizontalAdvance(uint32_t glyph_id, const MinikinPaint &paint) const; 37 void GetBounds(MinikinRect* bounds, uint32_t glyph_id, 38 const MinikinPaint& paint) const; 39 fontPath()40 const std::string& fontPath() const { return mFontPath; } 41 GetFontData()42 const void* GetFontData() const { return mFontData; } GetFontSize()43 size_t GetFontSize() const { return mFontSize; } GetFontIndex()44 int GetFontIndex() const { return mFontIndex; } GetAxes()45 const std::vector<minikin::FontVariation>& GetAxes() const { return mVariations; } 46 std::shared_ptr<MinikinFont> createFontWithVariation( 47 const std::vector<FontVariation>& variations) const; 48 private: 49 MinikinFontForTest() = delete; 50 MinikinFontForTest(const MinikinFontForTest&) = delete; 51 MinikinFontForTest& operator=(MinikinFontForTest&) = delete; 52 53 const std::string mFontPath; 54 const std::vector<FontVariation> mVariations; 55 const int mFontIndex; 56 void* mFontData; 57 size_t mFontSize; 58 }; 59 60 } // namespace minikin 61 62 #endif // MINIKIN_TEST_MINIKIN_FONT_FOR_TEST_H 63