1// LAF OS Library
2// Copyright (c) 2019-2020 Igara Studio S.A.
3// Copyright (c) 2012-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_FONT_H_INCLUDED
9#define OS_FONT_H_INCLUDED
10#pragma once
11
12#include "base/ints.h"
13#include "os/ref.h"
14
15#include <string>
16
17namespace os {
18
19 class Font;
20 class FontStyle;
21 class Typeface;
22 using FontRef = Ref<Font>;
23
24 enum class FontType {
25 Unknown,
26 SpriteSheet, // SpriteSheet
27 FreeType, // FreeType
28 Native, // Skia
29 };
30
31 class Font : public RefCount {
32 public:
33 Font() : m_fallback(nullptr) { }
34 virtual ~Font() { }
35 virtual FontType type() = 0;
36 virtual int height() const = 0;
37 virtual int textLength(const std::string& str) const = 0;
38 virtual bool isScalable() const = 0;
39 virtual void setSize(int size) = 0;
40 virtual void setAntialias(bool antialias) = 0;
41 virtual bool hasCodePoint(int codepoint) const = 0;
42
43 Font* fallback() const {
44 return m_fallback;
45 }
46 void setFallback(Font* font) {
47 m_fallback = font;
48 }
49
50 private:
51 Font* m_fallback;
52 };
53
54} // namespace os
55
56#endif
57