| 1 | // LAF FreeType Wrapper |
| 2 | // Copyright (c) 2020 Igara Studio S.A. |
| 3 | // Copyright (c) 2017 David Capello |
| 4 | // |
| 5 | // This file is released under the terms of the MIT license. |
| 6 | // Read LICENSE.txt for more information. |
| 7 | |
| 8 | #ifndef FT_HB_FACE_H_INCLUDED |
| 9 | #define FT_HB_FACE_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "base/string.h" |
| 13 | #include "ft/face.h" |
| 14 | |
| 15 | #include <hb.h> |
| 16 | #include <hb-ft.h> |
| 17 | |
| 18 | namespace ft { |
| 19 | |
| 20 | template<typename FaceFT> |
| 21 | class HBFace : public FaceFT { |
| 22 | public: |
| 23 | HBFace(FT_Face face) : FaceFT(face) { |
| 24 | m_font = (face ? hb_ft_font_create((FT_Face)face, nullptr): nullptr); |
| 25 | } |
| 26 | |
| 27 | ~HBFace() { |
| 28 | if (m_font) hb_font_destroy(m_font); |
| 29 | } |
| 30 | |
| 31 | hb_font_t* font() const { return m_font; } |
| 32 | |
| 33 | private: |
| 34 | hb_font_t* m_font; |
| 35 | }; |
| 36 | |
| 37 | typedef HBFace<FaceFT<SimpleCache> > Face; |
| 38 | |
| 39 | } // namespace ft |
| 40 | |
| 41 | #endif |
| 42 | |