libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
font.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <promeki/namespace.h>
14#include <promeki/string.h>
15#include <promeki/stringlist.h>
16#include <promeki/color.h>
17#include <promeki/paintengine.h>
18
19PROMEKI_NAMESPACE_BEGIN
20
45class Font {
46 public:
48 virtual ~Font();
49
50 Font(const Font &) = delete;
51 Font &operator=(const Font &) = delete;
52
62 void setFontFilename(const String &val);
63
68 const String &fontFilename() const { return _fontFilename; }
69
88 void setFontFallbacks(const StringList &val);
89
97 const StringList &fontFallbacks() const { return _fontFallbacks; }
98
103 void setFontSize(int val);
104
109 int fontSize() const { return _fontSize; }
110
115 void setForegroundColor(const Color &color);
116
121 const Color &foregroundColor() const { return _fg; }
122
131 void setBackgroundColor(const Color &color);
132
137 const Color &backgroundColor() const { return _bg; }
138
148 void setPaintEngine(const PaintEngine &pe);
149
154 const PaintEngine &paintEngine() const { return _paintEngine; }
155
163 void setKerningEnabled(bool val);
164
169 bool kerningEnabled() const { return _kerning; }
170
176 bool isValid() const;
177
185 virtual bool drawText(const String &text, int x, int y) = 0;
186
192 virtual int measureText(const String &text) = 0;
193
203 virtual int lineHeight() = 0;
204
213 virtual int ascender() = 0;
214
223 virtual int descender() = 0;
224
225 protected:
230 Font(const PaintEngine &pe);
231
246 virtual void onStateChanged();
247
259 virtual void onColorChanged();
260
272 String effectiveFilename() const;
273
289 StringList effectiveFallbacks() const;
290
291 String _fontFilename;
292 StringList _fontFallbacks;
293 int _fontSize = 12;
294 Color _fg = Color::White;
295 Color _bg = Color::Black;
296 PaintEngine _paintEngine;
297 bool _kerning = false;
298};
299
300PROMEKI_NAMESPACE_END
301
302#endif // PROMEKI_ENABLE_PROAV