StanfordCPPLib
gfont.h
1 /*
2  * File: gfont.h
3  * -------------
4  *
5  * @author Marty Stepp
6  * @version 2018/09/07
7  * - added doc comments for new documentation generation
8  * @version 2018/08/23
9  * - renamed to gfont.h to replace Java version
10  * @version 2018/07/05
11  * - initial version
12  */
13 
14 #include "private/init.h" // ensure that Stanford C++ lib is initialized
15 
16 #ifndef INTERNAL_INCLUDE
17 // signal that GUI system is in use (so it will be initialized)
18 #define SPL_QT_GUI_IN_USE 1
19 #include "private/initstudent.h" // insert necessary included code by student
20 #endif // INTERNAL_INCLUDE
21 
22 #ifndef _gfont_h
23 #define _gfont_h
24 
25 #include <string>
26 #include <QFont>
27 
28 #define INTERNAL_INCLUDE 1
29 #include "ginteractor.h"
30 #undef INTERNAL_INCLUDE
31 
44 class GFont {
45 public:
51  static void boldFont(GInteractor* interactor);
52 
58  static void changeFontSize(GInteractor* interactor, int dsize);
59 
65  static QFont changeFontSize(const QFont& font, int dsize);
66 
71  static QFont deriveQFont(const QFont& font, QFont::Weight weight = QFont::Normal, int size = -1);
72 
77  static QFont deriveQFont(const QFont& font, const string& fontFamily, QFont::Weight weight = QFont::Normal, int size = -1);
78 
84  static QFont deriveQFont(const string& font, QFont::Weight weight = QFont::Normal, int size = -1);
85 
91  static QFont deriveQFont(const string& font, const string& fontFamily, QFont::Weight weight = QFont::Normal, int size = -1);
92 
98  static void italicFont(GInteractor* interactor);
99 
104  static string toFontString(const QFont& font);
105 
109  static QFont toQFont(const string& fontString);
110 
116  static QFont toQFont(const QFont& basisFont, const string& fontString);
117 
118 private:
119  GFont(); // prevent construction
120  static QFont::StyleHint getStyleHint(const string& fontFamily);
121 };
122 
123 #endif // _gfont_h
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:42
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:53
static void italicFont(GInteractor *interactor)
Makes the given interactor&#39;s font italic.
Definition: gfont.cpp:102
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:53
This class contains static methods for dealing with fonts in our GUI system.
Definition: gfont.h:44
static string toFontString(const QFont &font)
Converts the given Qt font object into a font string such as "Helvetica-12-Bold". ...
Definition: gfont.cpp:111
static void boldFont(GInteractor *interactor)
Makes the given interactor&#39;s font bold.
Definition: gfont.cpp:36
static QFont toQFont(string fontString)
Converts a font string such as "Helvetica-12-Bold" into a Qt font object.
Definition: gfont.cpp:154