1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  * Copyright (C) 2004 by Riku Leino                                        *
9  * tsoots@gmail.com                                                        *
10  *                                                                         *
11  * This program is free software; you can redistribute it and/or modify    *
12  * it under the terms of the GNU General Public License as published by    *
13  * the Free Software Foundation; either version 2 of the License, or       *
14  * (at your option) any later version.                                     *
15  *                                                                         *
16  * This program is distributed in the hope that it will be useful,         *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
19  * GNU General Public License for more details.                            *
20  *                                                                         *
21  * You should have received a copy of the GNU General Public License       *
22  * along with this program; if not, write to the                           *
23  * Free Software Foundation, Inc.,                                         *
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.            *
25  ***************************************************************************/
26 
27 #ifndef GTFONT_H
28 #define GTFONT_H
29 
30 #include <vector>
31 
32 #include <QString>
33 #include "scribusapi.h"
34 
35 enum FontEffect {
36 	NORMAL,
37 	UNDERLINE,
38 	STRIKETHROUGH,
39 	SMALL_CAPS,
40 	SUPERSCRIPT,
41 	SUBSCRIPT,
42 	OUTLINE,
43 	FontEffectMAX
44 };
45 
46 enum FontWeight {
47 	NO_WEIGHT,
48 	DEMIBOLD,
49 	EXTRABLACK,
50 	EXTRABOLD,
51 	EXTRAHEAVY,
52 	EXTRALIGHT,
53 	SEMIBOLD,
54 	BLACK,
55 	BOLD,
56 	BOOK,
57 	DEMI,
58 	HEAVY,
59 	LIGHT,
60 	LITE,
61 	MEDIUM,
62 	REGULAR,
63 	ROMAN,
64 	FontWeightMAX
65 };
66 
67 enum FontSlant {
68 	NO_SLANT,
69 	ITALIC,
70 	OBLIQUE,
71 	FontSlantMAX
72 };
73 
74 enum FontWidth {
75 	NO_WIDTH,
76 	EXTRACONDENSED,
77 	SEMICONDENSED,
78 	ULTRACONDENSED,
79 	EXTRACOMPRESSED,
80 	SEMICOMPRESSED,
81 	ULTRACOMPRESSED,
82 	CONDENSED,
83 	COMPRESSED,
84 	FontWidthMAX
85 };
86 
87 /*
88 	Font will do the font search in Scribus and in case a font
89 	cannot be found it will launch the font substitution dialog.
90 */
91 class SCRIBUS_API gtFont
92 {
93 public:
94 	gtFont();
95 	gtFont(const gtFont& f);
96 	~gtFont();
97 
98 	typedef enum
99 	{
100 		familyWasSet = 1,
101 		weightWasSet = 2,
102 		slantWasSet = 4,
103 		widthWasSet = 8,
104 		sizeWasSet = 16,
105 		effectWasSet = 32,
106 		fillColorWasSet = 64,
107 		fillShadeWasSet = 128,
108 		strokeColorWasSet = 256,
109 		strokeShadeWasSet = 512,
110 		hscaleWasSet = 1024,
111 		kerningWasSet = 2048
112 	} wasSetFlags;
113 
114 	static const QString fontWeights[];
115 	static const QString fontSlants[];
116 	static const QString fontWidths[];
117 
118 	void    noEffects();
119 	bool    isToggled(FontEffect fe);
120 	bool    toggleEffect(FontEffect fe);
121 	int     getFlags();
122 	int     getEffectsValue();
123 	void	setName(const QString& newName);
124 	void    setFamily(const QString& newFamily);
125 	QString getFamily();
126 	void    setWeight(FontWeight newWeight);
127 	void    setWeight(const QString& newWeight);
128 	QString getWeight();
129 	void    setSlant(FontSlant newSlant);
130 	void    setSlant(const QString& newSlant);
131 	QString getSlant();
132 	void    setWidth(FontWidth newWidth);
133 	void    setWidth(const QString& newWidth);
134 	QString getWidth();
135 	void    setSize(int newSize);
136 	void    setSize(double newSize);
137 	void    setColor(const QString& newColor);
138 	void    setShade(int newShade);
139 	void    setStrokeColor(const QString& newColor);
140 	void    setStrokeShade(int newShade);
141 	QString getName();
142 	QString getName(uint i);
143 	static const int NAMECOUNT = 14;
144 	int     getSize();
145 	QString getColor();
146 	int     getShade();
147 	QString getStrokeColor();
148 	int     getStrokeShade();
149 	int     getHscale();
150 	void    setHscale(int newHscale);
151 	int     getKerning();
152 	void    setKerning(int newKerning);
153 
154 private:
155 	int     m_setflags {0};
156 	QString m_name;
157 	QString m_family;
158 	QString m_weight;
159 	QString m_slant;
160 	QString m_width;
161 	QString m_append;
162 	int     m_size {120};
163 	bool    m_fontEffects[FontEffectMAX];
164 	QString m_color {"Black"};
165 	int     m_shade {100};
166 	QString m_strokeColor {"Black"};
167 	int     m_strokeShade {100};
168 	/* Width of a character in percentages to it's "real width" */
169 	int  m_hscale {1000};
170 	int  m_kerning {0};
171 	bool m_useFullName {true};
172 	int  m_weightIndex {0};
173 	int  m_slantIndex {1};
174 	int  m_widthIndex {2};
175 	int  m_smallestIndex {-1};
176 	int  m_biggestIndex {-1};
177 	int  m_index {-1};
178 	int  m_tmpWeightIndex {-1};
179 	int  m_tmpSlantIndex {-1};
180 	int  m_tmpWidthIndex {-1};
181 
182 	void initArrays();
183 	void parseName();
184 	void parseWeight();
185 	void parseSlant();
186 	void parseWidth();
187 	void parseFamily();
188 	int  find(const QString& where, const QString& what);
189 };
190 
191 #endif // GTFONT_H
192