API Documentation
Loading...
Searching...
No Matches
TextConstructor.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: TextConstuctor
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Model.h>
34#include <NDEVR/Geometry.h>
35#include <NDEVR/Font.h>
36#include <NDEVR/Pointer.h>
37#if NDEVR_TEXT_MODEL
38struct FT_LibraryRec_;
39struct FT_FaceRec_;
40struct FT_Vector_;
41namespace NDEVR
42{
43 struct Font;
44 struct NDEVR_DESIGN_API FreeTypeLibrary
45 {
46 FreeTypeLibrary();
47 ~FreeTypeLibrary();
48 FT_LibraryRec_* m_ftLibrary;
49 };
50
51 struct NDEVR_DESIGN_API FreeTypeFace
52 {
53 FreeTypeFace();
54 FreeTypeFace(const FreeTypeLibrary &library, const Font& font);
55 FreeTypeFace(FreeTypeFace&& face);
56 ~FreeTypeFace();
57 FreeTypeFace& operator=(FreeTypeFace&& face) noexcept;
58 FT_FaceRec_* m_ftFace;
59 };
60 class NDEVR_DESIGN_API TextConstructor
61 {
62 public:
63 TextConstructor();
64 TextConstructor(const String& app_font, bool cache_font_geometry = true);
65 TextConstructor(const Font& font, bool cache_font_geometry = true);
66 Geometry getCharMesh(Model& parent, wchar symbol);
67 void ensureCharExists(wchar symbol);
68 fltp08 fontHeight() const;
69 Vector<2, fltp08> symbolAdvance(wchar symbol) const;
70 Vector<2, fltp08> symbolAdvance(wchar symbol_a, wchar symbol_b) const;
71 Vector<2, fltp08> fontSize() const;
72 void setFont(Font font, bool cache_font_geometry = true);
73 const Font& currentFont() const { return m_current_font; }
74 bool canConstructGeometry() const;
75 void cacheFont();
76 static DynamicPointer< TextConstructor> DefaultConstructor(Font font);
77 private:
78 void LoadGlyph(wchar symbol) const;
79 bool OutlineExists() const;
80 void ExtractOutline();
81 void ComputeViewBox();
82
83 static int MoveToFunction(const FT_Vector_ *to, void *user);
84 static int LineToFunction(const FT_Vector_ *to, void *user);
85 static int ConicToFunction(const FT_Vector_ *control, const FT_Vector_ *to, void *user);
86 static int CubicToFunction(const FT_Vector_ *controlOne, const FT_Vector_ *controlTwo, const FT_Vector_ *to, void *user);
87 Geometry currentMesh();
88
89 private:
90 UUID textUUID(wchar symbol) const;
91 // These two lines initialize the library and the face;
92 // the order is important!
93 Font m_current_font;
94 FreeTypeLibrary m_library;
95 FreeTypeFace m_face;
96 uint04 m_curve_seg;
97 DynamicPointer<Model> m_font_model;
98 mutable Dictionary<UUID, Vector<2, fltp08>> m_symbol_advance;
99 mutable Dictionary<UUID, Dictionary<UUID, uint04>> m_model_copy;
100 Dictionary<UUID, Geometry> m_geometry;
101 wchar m_current_char;
102 Vector<2, fltp08> m_last_point;
103
104 };
105
106}
107#endif
108
109
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
wchar_t wchar
Definition BaseValues.hpp:184
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181