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
41 /**--------------------------------------------------------------------------------------------------
42 \brief Information for how to display text data.
43
44 **/
68
69 /**--------------------------------------------------------------------------------------------------
70 \brief Stores many different types of font
71
72 **/
74 {
75 public:
76 static constexpr char DefaultFont[8] = "Default";
77 NDEVR_BASE_API static void SetApplicationFont(const String& app_font, const Font& font);
78 NDEVR_BASE_API static const Font& ApplicationFont(const String& app_font);
79 NDEVR_BASE_API static bool HasApplicationFont(const String& app_font);
81 NDEVR_BASE_API static void PullFontFromFolder(const File& folder);
82 NDEVR_BASE_API static bool HasFontFile(const String& font_name);
83 NDEVR_BASE_API static void SetFontFile(const String& font_name, const File& file, uint04 index = 0);
84 NDEVR_BASE_API static void SetSettingsFile(const File& file);
87 NDEVR_BASE_API static void AddFontListener(const String& app_font, UUID id, std::function<void(const String&)> callback);
88 NDEVR_BASE_API static void RemoveFontListener(const String& app_font, UUID id);
89 protected:
90 NDEVR_BASE_API static File TryFontName(const String& family);
91 protected:
98 };
99 /**--------------------------------------------------------------------------------------------------
100 \brief text that is formatted the same way, typically part of a bigger group of text
101
102 **/
104 {
107 bool operator==(const TextBlock& block) const
108 {
109 return text == block.text && font == block.font;
110 }
111 bool operator!=(const TextBlock& block) const
112 {
113 return text != block.text || font != block.font;
114 }
115 };
116
117 /**--------------------------------------------------------------------------------------------------
118 \brief How to align text into a given container
119
120 **/
121 enum class TextAlignment
122 {
123 e_left = 0x01
124 , e_right = 0x02
125 , e_top = 0x04
126 , e_bottom = 0x08
127 , e_bottom_base = 0x10
132 };
133 inline uint01 operator|(const TextAlignment& a, const TextAlignment& b)
134 {
135 return cast<uint01>(a) | cast<uint01>(b);
136 }
137}
138
#define NDEVR_BASE_API
Definition DLLInfo.h:57
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
Stores many different types of font.
Definition Font.h:74
static void PullFontFromFolder(const File &folder)
static void SetSettingsFile(const File &file)
static File FindBestFitFontFile(const Font &font)
static File TryFontName(const String &family)
static void SaveFontSettings()
static Dictionary< String, Font > s_system_fonts
Definition Font.h:92
static void SetApplicationFont(const String &app_font, const Font &font)
static bool HasFontFile(const String &font_name)
static Dictionary< String, Font > s_application_fonts
Definition Font.h:93
static bool HasApplicationFont(const String &app_font)
static Dictionary< String, uint04 > s_font_indices
Definition Font.h:95
static File s_settings_file
Definition Font.h:97
static void ReadFontSettings()
static constexpr char DefaultFont[8]
Definition Font.h:76
static const Font & ApplicationFont(const String &app_font)
static void SetFontFile(const String &font_name, const File &file, uint04 index=0)
static void AddFontListener(const String &app_font, UUID id, std::function< void(const String &)> callback)
static Dictionary< String, String > s_font_files
Definition Font.h:94
static void RemoveFontListener(const String &app_font, UUID id)
static Dictionary< String, Dictionary< UUID, std::function< void(const String &)> > > s_app_font_listener
Definition Font.h:96
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
The core String class for the NDEVR API.
Definition String.h:69
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
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:80
TextAlignment
How to align text into a given container.
Definition Font.h:122
uint01 operator|(const TextAlignment &a, const TextAlignment &b)
Definition Font.h:133
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Information for how to display text data.
Definition Font.h:46
bool operator==(const Font &font) const
bool is_bold
Definition Font.h:56
fltp08 point_size
Definition Font.h:49
RGBColor color
Definition Font.h:54
bool is_strikethrough
Definition Font.h:60
bool is_italic
Definition Font.h:57
fltp08 pixel_size
Definition Font.h:50
String name
Definition Font.h:47
uint01 alignment
Definition Font.h:55
bool operator!=(const Font &font) const
void setFile(const File &file)
Definition Font.h:64
File m_file
Definition Font.h:66
bool is_underline
Definition Font.h:58
uint04 index
Definition Font.h:53
File getFile() const
String app_font_name
Definition Font.h:48
bool is_overstrike
Definition Font.h:59
fltp08 fixed_width
Definition Font.h:51
fltp08 tab_advance
Definition Font.h:52
text that is formatted the same way, typically part of a bigger group of text
Definition Font.h:104
Font font
Definition Font.h:106
bool operator!=(const TextBlock &block) const
Definition Font.h:111
bool operator==(const TextBlock &block) const
Definition Font.h:107
String text
Definition Font.h:105