API Documentation
Loading...
Searching...
No Matches
Font.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: Base
28File: Font
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/File.h>
35#include <NDEVR/RGBColor.h>
36#include <NDEVR/Dictionary.h>
37namespace NDEVR
38{
39 class UUID;
40 struct Font
41 {
51 bool is_bold = false;
52 bool is_italic = false;
53 bool is_underline = false;
54 bool is_overstrike = false;
55 bool is_strikethrough = false;
56 NDEVR_BASE_API bool operator==(const Font& font) const;
57 NDEVR_BASE_API bool operator!=(const Font& font) const;
59 void setFile(const File& file) { m_file = file; }
60 protected:
61 mutable File m_file;
62 };
64 {
65 public:
66 static constexpr char DefaultFont[8] = "Default";
67 NDEVR_BASE_API static void SetApplicationFont(const String& app_font, const Font& font);
68 NDEVR_BASE_API static const Font& ApplicationFont(const String& app_font);
69 NDEVR_BASE_API static bool HasApplicationFont(const String& app_font);
70 NDEVR_BASE_API static File FindBestFitFontFile(const Font& font);
71 NDEVR_BASE_API static void PullFontFromFolder(const File& folder);
72 NDEVR_BASE_API static bool HasFontFile(const String& font_name);
73 NDEVR_BASE_API static void SetFontFile(const String& font_name, const File& file, uint04 index = 0);
74 NDEVR_BASE_API static void SetSettingsFile(const File& file);
75 NDEVR_BASE_API static void SaveFontSettings();
76 NDEVR_BASE_API static void ReadFontSettings();
77 NDEVR_BASE_API static void AddFontListener(const String& app_font, UUID id, std::function<void(const String&)> callback);
78 NDEVR_BASE_API static void RemoveFontListener(const String& app_font, UUID id);
79 protected:
80 NDEVR_BASE_API static File TryFontName(const String& family);
81 protected:
88 };
89 struct TextBlock
90 {
93 bool operator==(const TextBlock& block) const
94 {
95 return text == block.text && font == block.font;
96 }
97 bool operator!=(const TextBlock& block) const
98 {
99 return text != block.text || font != block.font;
100 }
101 };
102
103 enum class TextAlignment
104 {
105 e_left = 0x01
106 , e_right = 0x02
107 , e_top = 0x04
108 , e_bottom = 0x08
109 , e_bottom_base = 0x10
114 };
115 inline uint01 operator|(const TextAlignment& a, const TextAlignment& b)
116 {
117 return cast<uint01>(a) | cast<uint01>(b);
118 }
119}
120
#define NDEVR_BASE_API
Definition DLLInfo.h:78
Definition Dictionary.h:48
Definition File.h:47
Definition Font.h:64
static NDEVR_BASE_API void SetApplicationFont(const String &app_font, const Font &font)
Definition Font.cpp:195
static NDEVR_BASE_API File FindBestFitFontFile(const Font &font)
Definition Font.cpp:39
static NDEVR_BASE_API void ReadFontSettings()
Definition Font.cpp:119
static NDEVR_BASE_API const Font & ApplicationFont(const String &app_font)
Definition Font.cpp:209
static NDEVR_BASE_API void AddFontListener(const String &app_font, UUID id, std::function< void(const String &)> callback)
Definition Font.cpp:133
static NDEVR_BASE_API Dictionary< String, Font > s_application_fonts
Definition Font.h:83
static NDEVR_BASE_API Dictionary< String, uint04 > s_font_indices
Definition Font.h:85
static NDEVR_BASE_API File TryFontName(const String &family)
Definition Font.cpp:147
static NDEVR_BASE_API void PullFontFromFolder(const File &folder)
Definition Font.cpp:67
static NDEVR_BASE_API void SetFontFile(const String &font_name, const File &file, uint04 index=0)
Definition Font.cpp:91
static NDEVR_BASE_API void SetSettingsFile(const File &file)
Definition Font.cpp:97
static NDEVR_BASE_API void RemoveFontListener(const String &app_font, UUID id)
Definition Font.cpp:138
static NDEVR_BASE_API void SaveFontSettings()
Definition Font.cpp:103
static NDEVR_BASE_API File s_settings_file
Definition Font.h:87
static NDEVR_BASE_API Dictionary< String, String > s_font_files
Definition Font.h:84
static constexpr char DefaultFont[8]
Definition Font.h:66
static NDEVR_BASE_API Dictionary< String, Dictionary< UUID, std::function< void(const String &)> > > s_app_font_listener
Definition Font.h:86
static NDEVR_BASE_API bool HasApplicationFont(const String &app_font)
Definition Font.cpp:216
static NDEVR_BASE_API bool HasFontFile(const String &font_name)
Definition Font.cpp:86
static NDEVR_BASE_API Dictionary< String, Font > s_system_fonts
Definition Font.h:82
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Definition String.h:40
Definition UUID.h:66
Definition ACIColor.h:37
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
TextAlignment
Definition Font.h:104
uint01 operator|(const TextAlignment &a, const TextAlignment &b)
Definition Font.h:115
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition BaseValues.hpp:272
Definition Font.h:41
NDEVR_BASE_API bool operator==(const Font &font) const
Definition Font.cpp:7
bool is_bold
Definition Font.h:51
fltp08 point_size
Definition Font.h:44
RGBColor color
Definition Font.h:49
bool is_strikethrough
Definition Font.h:55
bool is_italic
Definition Font.h:52
fltp08 pixel_size
Definition Font.h:45
String name
Definition Font.h:42
uint01 alignment
Definition Font.h:50
NDEVR_BASE_API bool operator!=(const Font &font) const
Definition Font.cpp:20
void setFile(const File &file)
Definition Font.h:59
File m_file
Definition Font.h:61
bool is_underline
Definition Font.h:53
uint04 index
Definition Font.h:48
NDEVR_BASE_API File getFile() const
Definition Font.cpp:33
String app_font_name
Definition Font.h:43
bool is_overstrike
Definition Font.h:54
fltp08 fixed_width
Definition Font.h:46
fltp08 tab_advance
Definition Font.h:47
Definition Font.h:90
Font font
Definition Font.h:92
bool operator!=(const TextBlock &block) const
Definition Font.h:97
bool operator==(const TextBlock &block) const
Definition Font.h:93
String text
Definition Font.h:91