1// LAF OS Library
2// Copyright (C) 2020 Igara Studio S.A.
3// Copyright (C) 2016-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 OS_COMMON_FREETYPE_FONT_H_INCLUDED
9#define OS_COMMON_FREETYPE_FONT_H_INCLUDED
10#pragma once
11
12#include "ft/hb_face.h"
13#include "ft/lib.h"
14#include "os/font.h"
15
16namespace os {
17 class Font;
18
19 class FreeTypeFont : public Font {
20 public:
21 using Face = ft::Face;
22
23 FreeTypeFont(ft::Lib& lib,
24 const char* filename,
25 const int height);
26 ~FreeTypeFont();
27
28 bool isValid() const;
29 FontType type() override;
30 int height() const override;
31 int textLength(const std::string& str) const override;
32 bool isScalable() const override;
33 void setSize(int size) override;
34 void setAntialias(bool antialias) override;
35 bool hasCodePoint(int codepoint) const override;
36
37 Face& face() { return m_face; }
38
39 private:
40 mutable Face m_face;
41 };
42
43 Ref<FreeTypeFont> load_free_type_font(ft::Lib& lib,
44 const char* filename,
45 const int height);
46
47} // namespace os
48
49#endif
50