SGL
gfont.h
1 /*
2  * File: gfont.h
3  * -------------
4  *
5  * @author Marty Stepp
6  * @version 2021/04/09
7  * - added sgl namespace
8  * @version 2019/04/30
9  * - added changeFontSize for a GText*
10  * @version 2018/09/07
11  * - added doc comments for new documentation generation
12  * @version 2018/08/23
13  * - renamed to gfont.h to replace Java version
14  * @version 2018/07/05
15  * - initial version
16  */
17 
18 
19 #ifndef _gfont_h
20 #define _gfont_h
21 
22 #include <string>
23 #include <QFont>
24 
25 #include "ginteractor.h"
26 #include "gobjects.h"
27 
28 namespace sgl {
29 
42 class GFont {
43 public:
49  static void boldFont(GInteractor* interactor);
50 
56  static void changeFontSize(GInteractor* interactor, int dsize);
57 
63  static void changeFontSize(GText* label, int dsize);
64 
70  static QFont changeFontSize(const QFont& font, int dsize);
71 
76  static QFont deriveQFont(const QFont& font, QFont::Weight weight = QFont::Normal, int size = -1);
77 
82  static QFont deriveQFont(const QFont& font, const string& fontFamily, QFont::Weight weight = QFont::Normal, int size = -1);
83 
89  static QFont deriveQFont(const string& font, QFont::Weight weight = QFont::Normal, int size = -1);
90 
96  static QFont deriveQFont(const string& font, const string& fontFamily, QFont::Weight weight = QFont::Normal, int size = -1);
97 
103  static void italicFont(GInteractor* interactor);
104 
109  static string toFontString(const QFont& font);
110 
114  static QFont toQFont(const string& fontString);
115 
121  static QFont toQFont(const QFont& basisFont, const string& fontString);
122 
123 private:
124  GFont(); // prevent construction
125  static QFont::StyleHint getStyleHint(const string& fontFamily);
126 };
127 
128 } // namespace sgl
129 
130 #endif // _gfont_h
static QFont toQFont(string fontString)
Converts a font string such as "Helvetica-12-Bold" into a Qt font object.
Definition: gfont.cpp:159
static void italicFont(GInteractor *interactor)
Makes the given interactor&#39;s font italic.
Definition: gfont.cpp:109
This class contains static methods for dealing with fonts in our GUI system.
Definition: gfont.h:42
static string toFontString(const QFont &font)
Converts the given Qt font object into a font string such as "Helvetica-12-Bold". ...
Definition: gfont.cpp:118
static QFont deriveQFont(const QFont &font, QFont::Weight weight=QFont::Normal, int size=-1)
Modifies the given font object, changing its weight and/or size to the given values, and returning the new modified font.
Definition: gfont.cpp:60
Definition: console.h:45
static void boldFont(GInteractor *interactor)
Makes the given interactor&#39;s font bold.
Definition: gfont.cpp:37
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:52
This graphical object subclass represents a text string.
Definition: gobjects.h:1446
static void changeFontSize(GInteractor *interactor, int dsize)
Modifies the font of the given interactor, changing its size by the given number of points...
Definition: gfont.cpp:43