Photon microGUI widgets library 0.6.0
Font.h
1
2#ifndef PHWIDGETS_FONT_H
3#define PHWIDGETS_FONT_H
4
5#include "./../service/property.hpp"
6#include "./../service/bitmask.hpp"
7
8#include <photon/Pf.h>
9
10
11#include <string>
12#include <vector>
13
14namespace PhWidgets
15{
16 using namespace cppproperties;
17
18 namespace Drawing
19 {
21
47 struct FontStyle
48 {
50 {
51 Bold = PF_STYLE_BOLD,
52 Italic = PF_STYLE_ITALIC,
53 Regular = 0,
54 Underline = PF_STYLE_ULINE,
55 DoubleUnderline = PF_STYLE_DULINE,
56 Antialias = PF_STYLE_ANTIALIAS,
57 Scalable = PF_SCALABLE,
58 Bitmap = PF_BITMAP
59 };
60 };
61
62 namespace typedefs
63 {
64 typedef
65 cppbitmasks::bitmask<
66 unsigned short,
68 static_cast<unsigned short>(FontStyle::Antialias) |
69 static_cast<unsigned short>(FontStyle::Bitmap) |
70 static_cast<unsigned short>(FontStyle::Bold) |
71 static_cast<unsigned short>(FontStyle::DoubleUnderline) |
72 static_cast<unsigned short>(FontStyle::Italic) |
73 static_cast<unsigned short>(FontStyle::Regular) |
74 static_cast<unsigned short>(FontStyle::Scalable) |
75 static_cast<unsigned short>(FontStyle::Underline)
76 > font_style_bitmask;
77 }
78
81 {
83 {
84 Monospace = PHFONT_INFO_PROP,
85 SansSerif = PHFONT_INFO_SANSERIF,
86 Serif = PHFONT_INFO_SERIF
87 };
88 };
89
91
102 {
103 protected:
104 FontCollection() {}
105 private:
106 struct FontCollectionDetail
107 {
108 static const std::vector<FontDetails>& getFamilies();
109 };
110 public:
111 static const property<const std::vector<FontDetails>&>::
112 bind_static<&FontCollectionDetail::getFamilies> Families;
113 };
114
117 public FontCollection
118 {
119 public:
121 };
122
125 class PrivateFontCollection;
126
129 {
130 public:
132
138
140
145 FontFamily(const FontDetails &fdetails);
146
148
153 FontFamily(std::string name);
154
156
162 FontFamily(std::string name, const FontCollection &fcollection);
163
165
169 FontFamily(const FontFamily &other);
170
172
177
179
183 bool operator==(const FontFamily &other) const;
184
186
190 bool operator!=(const FontFamily &other) const;
191
193
197 bool operator<(const FontFamily &other) const;
198
201
204 int GetLineSpacing(typedefs::font_style_bitmask fstyle) const;
205
207
210 bool IsStyleAvailable(typedefs::font_style_bitmask fstyle) const;
211
212 operator FontDetails() const;
213
214 private:
215 FontDetails _fdetails;
216 std::string _name;
217
218 public:
220
227 const std::string &Name;
228 };
229
231 class Font
232 {
233 typedef FontID* font_id_type;
234
235 public:
236
238
245 Font(const Font &other, typedefs::font_style_bitmask fstyle);
246
248
254 Font(FontFamily ffamily, std::uint32_t size, typedefs::font_style_bitmask fstyle = FontStyle::Regular);
255
257
261 Font(font_id_type fid);
262
263 //Font(FontFamily, float, FontStyle, GraphicsUnit);
264 //Font(FontFamily, float, GraphicsUnit)
265
267
271 Font(const Font &other);
272
274
278 Font &operator=(const Font &other);
279
281
285 bool operator==(const Font &other) const;
286
288
292 bool operator!=(const Font &other) const;
293
295
299 bool operator<(const Font &other) const;
300
302 operator const font_id_type() const;
303
306
307
309 const bool &Bold;
310
313
315 const std::uint32_t &Height;
316
318 const bool &Italic;
319
321 const std::string &Name;
322
324 const std::uint32_t &Size;
325
326 // Gets the name of the Font originally specified.
327 //const std::string &OriginalFontName;
328
329 /*
330
331
332 // Gets a byte value that specifies the GDI character set that this Font uses.
333 // GdiCharSet
334
335 // Gets a Boolean value that indicates whether this Font is derived from a GDI vertical Font.
336 // GdiVerticalFont
337
338
339 // Gets a value indicating whether the Font is a member of SystemFonts.
340 // IsSystemFont
341
342
343
344 Gets the em-size of this Font measured in the units specified by the Unit property.
345 SizeInPoints
346
347
348 Strikeout
349
350 Gets a value that indicates whether this Font specifies a horizontal line through the Font.
351 Style
352
353 Gets style information for this Font.
354 SystemFontName
355
356 Gets the name of the system Font if the IsSystemFont property returns true.
357 Underline
358
359 Gets a value that indicates whether this Font is underlined.
360 Unit
361
362 Gets the unit of measure for this Font.*/
364
365 /*Methods
366
367 Returns the line spacing, in pixels, of this Font.
368 GetHeight() */
369
370 private:
371
372 font_id_type _fid;
373 std::string _fname;
374 bool _bold, _italic;
375 std::uint32_t _height, _size;
376 FontFamily _ffamily;
377 };
378
379 bool operator==(const GenericFontFamilies::eGenericFontFamilies &lhs, const FontFamily &rhs);
380 bool operator!=(const GenericFontFamilies::eGenericFontFamilies &lhs, const FontFamily &rhs);
381 bool operator<(const GenericFontFamilies::eGenericFontFamilies &lhs, const FontFamily &rhs);
382 } // namespace Drawing
383} // namespace PhWidgets
384
385PhWidgets::Drawing::typedefs::font_style_bitmask operator|(const PhWidgets::Drawing::FontStyle::eFontStyle &flag1, const PhWidgets::Drawing::FontStyle::eFontStyle &flag2);
386PhWidgets::Drawing::typedefs::font_style_bitmask operator&(const PhWidgets::Drawing::FontStyle::eFontStyle &flag1, const PhWidgets::Drawing::FontStyle::eFontStyle &flag2);
387PhWidgets::Drawing::typedefs::font_style_bitmask operator^(const PhWidgets::Drawing::FontStyle::eFontStyle &flag1, const PhWidgets::Drawing::FontStyle::eFontStyle &flag2);
388
389#endif // PHWIDGETS_FONT_H
Provides a base class for installed and private font collections.
Definition: Font.h:102
Defines a group of type faces having a similar basic design and certain variations in styles....
Definition: Font.h:129
bool operator<(const FontFamily &other) const
Compares FontFamilys.
int GetLineSpacing(typedefs::font_style_bitmask fstyle) const
FontFamily(const FontFamily &other)
(copy constructor)
bool operator==(const FontFamily &other) const
Compares FontFamilys.
const std::string & Name
Gets the name of this FontFamily.
Definition: Font.h:227
bool operator!=(const FontFamily &other) const
Compares FontFamilys.
FontFamily(std::string name, const FontCollection &fcollection)
(constructor)
FontFamily(const FontDetails &fdetails)
(constructor)
FontFamily & operator=(const FontFamily &other)
Assigns value in FontFamily.
FontFamily(GenericFontFamilies::eGenericFontFamilies ffamily)
(constructor)
bool IsStyleAvailable(typedefs::font_style_bitmask fstyle) const
Indicates whether the specified FontStyle::eFontStyle enumeration is available.
FontFamily(std::string name)
(constructor)
Defines a particular format for text, including font face, size, and style attributes....
Definition: Font.h:232
Font & operator=(const Font &other)
Assigns value in Font.
bool operator<(const Font &other) const
Compares Fonts.
const std::uint32_t & Size
Gets the em-size, in points, of this Font.
Definition: Font.h:324
Font(FontFamily ffamily, std::uint32_t size, typedefs::font_style_bitmask fstyle=FontStyle::Regular)
(constructor)
bool operator!=(const Font &other) const
Compares Fonts.
const std::uint32_t & Height
Gets the line spacing of this Font.
Definition: Font.h:315
const bool & Italic
Gets a value that indicates whether this Font has the italic style applied.
Definition: Font.h:318
Font(font_id_type fid)
(constructor)
const FontFamily & Family
Gets the FontFamily associated with this Font.
Definition: Font.h:312
Font(const Font &other)
(copy constructor)
bool operator==(const Font &other) const
Compares Fonts.
const bool & Bold
Gets a value that indicates whether this Font is bold.
Definition: Font.h:309
const std::string & Name
Gets the face name of this Font.
Definition: Font.h:321
Font(const Font &other, typedefs::font_style_bitmask fstyle)
(constructor)
Represents the fonts installed on the system. This class cannot be inherited.
Definition: Font.h:118
The main namespace for all widgets.
Definition: Basic.h:11
Specifies style information applied to text.
Definition: Font.h:48
eFontStyle
Definition: Font.h:50
@ DoubleUnderline
Double underlined text.
Definition: Font.h:55
@ Underline
Underlined text.
Definition: Font.h:54
@ Italic
Italic text.
Definition: Font.h:52
@ Bitmap
Bitmap text.
Definition: Font.h:58
@ Antialias
Antialias text.
Definition: Font.h:56
@ Regular
Normal text.
Definition: Font.h:53
@ Scalable
Scalable text.
Definition: Font.h:57
@ Bold
Bold text.
Definition: Font.h:51
Specifies a generic FontFamily object.
Definition: Font.h:81
eGenericFontFamilies
Definition: Font.h:83
@ SansSerif
A generic Sans Serif FontFamily object.
Definition: Font.h:85
@ Monospace
A generic Monospace FontFamily object.
Definition: Font.h:84
@ Serif
A generic Serif FontFamily object.
Definition: Font.h:86