11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
20PROMEKI_NAMESPACE_BEGIN
80class FastFont :
public Font {
83 using UPtr = UniquePtr<FastFont>;
101 bool underline =
false;
108 FastFont(
const PaintEngine &pe);
111 ~FastFont()
override;
113 bool drawText(
const String &text,
int x,
int y)
override;
114 int measureText(
const String &text)
override;
115 int lineHeight()
override;
116 int ascender()
override;
117 int descender()
override;
129 bool drawText(
const String &text,
int x,
int y,
const DrawStyle &style);
140 int measureText(
const String &text,
const DrawStyle &style);
143 void onStateChanged()
override;
146 void onColorChanged()
override;
150 uint32_t codepoint = 0;
153 uint8_t styleFlags = 0;
154 bool operator<(
const GlyphKey &o)
const {
155 if (codepoint != o.codepoint)
return codepoint < o.codepoint;
156 if (fgRGBA != o.fgRGBA)
return fgRGBA < o.fgRGBA;
157 if (bgRGBA != o.bgRGBA)
return bgRGBA < o.bgRGBA;
158 return styleFlags < o.styleFlags;
160 bool operator==(
const GlyphKey &o)
const {
161 return codepoint == o.codepoint && fgRGBA == o.fgRGBA
162 && bgRGBA == o.bgRGBA && styleFlags == o.styleFlags;
167 UncompressedVideoPayload::Ptr payload;
180 void *face =
nullptr;
185 bool ensureFontLoaded();
186 bool loadFace(
const String &path, LoadedFace &out);
187 const CachedGlyph *getGlyph(uint32_t codepoint,
const GlyphKey &key,
const Color &fg,
const Color &bg);
188 void invalidateGlyphs();
189 void invalidateFont();
190 void invalidateAll();
195 GlyphKey makeKey(uint32_t codepoint,
const DrawStyle &style, Color &outFg, Color &outBg)
const;
198 static uint32_t colorKey(
const Color &c);
205 int resolveFaceIndex(uint32_t codepoint)
const;
207 void *_ftLibrary =
nullptr;
208 List<LoadedFace> _ftFaces;
213 int _underlineThickness = 1;
215 int _underlinePosition = 0;
226 Map<GlyphKey, CachedGlyph> _glyphCache;