• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <string>
21 
22 #include "minikin/MinikinFont.h"
23 
24 #include <ft2build.h>
25 #include FT_FREETYPE_H
26 
27 #include "minikin/Macros.h"
28 
29 namespace minikin {
30 
31 class FreeTypeMinikinFontForTest : public MinikinFont {
32 public:
33     FreeTypeMinikinFontForTest(const std::string& font_path, int index);
FreeTypeMinikinFontForTest(const std::string & font_path)34     FreeTypeMinikinFontForTest(const std::string& font_path)
35             : FreeTypeMinikinFontForTest(font_path, 0) {}
36     virtual ~FreeTypeMinikinFontForTest();
37 
38     // MinikinFont overrides.
39     float GetHorizontalAdvance(uint32_t glyph_id, const MinikinPaint& paint,
40                                const FontFakery& fakery) const override;
41     void GetBounds(MinikinRect* bounds, uint32_t glyph_id, const MinikinPaint& paint,
42                    const FontFakery& fakery) const override;
43     void GetFontExtent(MinikinExtent* extent, const MinikinPaint& paint,
44                        const FontFakery& fakery) const override;
45 
fontPath()46     const std::string& fontPath() const { return mFontPath; }
47 
GetFontData()48     const void* GetFontData() const { return mFontData; }
GetFontSize()49     size_t GetFontSize() const { return mFontSize; }
GetFontIndex()50     int GetFontIndex() const { return mFontIndex; }
GetAxes()51     const std::vector<minikin::FontVariation>& GetAxes() const { return mAxes; }
52 
53 private:
54     const std::string mFontPath;
55     const int mFontIndex;
56     void* mFontData;
57     size_t mFontSize;
58     std::vector<minikin::FontVariation> mAxes;
59 
60     FT_Library mFtLibrary;
61     FT_Face mFtFace;
62 
63     MINIKIN_PREVENT_COPY_AND_ASSIGN(FreeTypeMinikinFontForTest);
64 };
65 
66 }  // namespace minikin
67 
68 #endif  // MINIKIN_TEST_FREE_TYPE_MINIKIN_FONT_FOR_TEST_H
69