1 /* 2 * Copyright (C) 2018 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_FREE_TYPE_MINIKIN_FONT_FOR_TEST_H 18 #define MINIKIN_TEST_FREE_TYPE_MINIKIN_FONT_FOR_TEST_H 19 20 #include "minikin/MinikinFont.h" 21 22 #include <ft2build.h> 23 #include FT_FREETYPE_H 24 25 #include "minikin/Macros.h" 26 27 namespace minikin { 28 29 class FreeTypeMinikinFontForTest : public MinikinFont { 30 public: 31 FreeTypeMinikinFontForTest(const std::string& font_path, int index); FreeTypeMinikinFontForTest(const std::string & font_path)32 FreeTypeMinikinFontForTest(const std::string& font_path) 33 : FreeTypeMinikinFontForTest(font_path, 0) {} 34 virtual ~FreeTypeMinikinFontForTest(); 35 36 // MinikinFont overrides. 37 float GetHorizontalAdvance(uint32_t glyph_id, const MinikinPaint& paint, 38 const FontFakery& fakery) const override; 39 void GetBounds(MinikinRect* bounds, uint32_t glyph_id, const MinikinPaint& paint, 40 const FontFakery& fakery) const override; 41 void GetFontExtent(MinikinExtent* extent, const MinikinPaint& paint, 42 const FontFakery& fakery) const override; 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 { return mAxes; } 50 51 private: 52 const std::string mFontPath; 53 const int mFontIndex; 54 void* mFontData; 55 size_t mFontSize; 56 std::vector<minikin::FontVariation> mAxes; 57 58 FT_Library mFtLibrary; 59 FT_Face mFtFace; 60 61 MINIKIN_PREVENT_COPY_AND_ASSIGN(FreeTypeMinikinFontForTest); 62 }; 63 64 } // namespace minikin 65 66 #endif // MINIKIN_TEST_FREE_TYPE_MINIKIN_FONT_FOR_TEST_H 67