33#include <NDEVR/Model.h>
34#include <NDEVR/Geometry.h>
35#include <NDEVR/Font.h>
36#include <NDEVR/Pointer.h>
48 struct NDEVR_DESIGN_API FreeTypeLibrary
56 FT_LibraryRec_* library;
73 struct NDEVR_DESIGN_API FreeTypeFace
81 FreeTypeFace(
const FreeTypeLibrary &library,
const Font& font);
85 FreeTypeFace(FreeTypeFace&& face);
93 FreeTypeFace& operator=(FreeTypeFace&& face)
noexcept;
101 class NDEVR_DESIGN_API TextConstructor
110 TextConstructor(
const StringView& app_font,
bool cache_font_geometry =
true);
115 TextConstructor(
const Font& font,
bool cache_font_geometry =
true);
124 Geometry getCharMesh(Model& parent, wchar symbol)
const;
128 void ensureCharExists(wchar symbol);
132 fltp08 fontHeight()
const;
136 fltp08 curveLength()
const;
139 void cacheIfNeeded();
144 Vector<2, fltp08> symbolAdvance(wchar symbol)
const;
151 Vector<2, fltp08> symbolAdvance(wchar symbol_a, wchar symbol_b)
const;
155 Vector<2, fltp08> fontSize()
const;
160 void setFont(Font font,
bool cache_font_geometry =
true);
164 const Font& currentFont()
const {
return m_font; }
168 bool canConstructGeometry()
const;
176 const Font& fontForChar(
wchar_t symbol)
const;
183 static ConstPointer<TextConstructor> DefaultConstructor(
const Font& font,
const StringView& chars_to_ensure_exist);
188 bool loadGlyph(wchar symbol);
193 bool OutlineExists()
const;
197 void ExtractOutline();
201 void computeViewBox(Geometry& geo);
207 static int MoveToFunction(
const FT_Vector_ *to,
void *user);
213 static int LineToFunction(
const FT_Vector_ *to,
void *user);
220 static int ConicToFunction(
const FT_Vector_ *control,
const FT_Vector_ *to,
void *user);
228 static int CubicToFunction(
const FT_Vector_ *controlOne,
const FT_Vector_ *controlTwo,
const FT_Vector_ *to,
void *user);
232 Geometry currentMesh();
238 UUID textUUID(wchar symbol)
const;
241 FreeTypeLibrary m_library;
243 fltp08 m_curve_length = 10.0;
244 DynamicPointer<Model> m_font_model;
245 mutable Dictionary<UUID, Dictionary<UUID, uint04>> m_model_copy;
246 Dictionary<UUID, Geometry> m_geometry;
247 Dictionary<wchar_t, Font> m_fallback_fonts;
248 wchar m_current_char =
'\0';
249 Vector<2, fltp08> m_last_point;
250 bool m_needs_recache =
false;
Information for how to display text data.
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.
wchar_t wchar
Allias for wchar_t, a value that represents a character of two bytes in size.