1 // Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef TEXT_FONTCONFIG_H
5 #define TEXT_FONTCONFIG_H
6 
7 #include "libs.h"
8 #include <string>
9 
10 namespace Text {
11 
12 	// WARNING: FontConfig is intended to be immutable; internal values shall not be changed
13 	class FontConfig {
14 	public:
15 		// XXX scale is to support to the old UI, and will be removed
16 		FontConfig(const std::string &name, float scaleX = 1.0f, float scaleY = 1.0f);
17 
18 		struct Face {
FaceFace19 			Face(const std::string &fontFile_, int pixelWidth_, int pixelHeight_, float advanceXAdjustment_, Uint32 rangeMin_, Uint32 rangeMax_) :
20 				fontFile(fontFile_),
21 				pixelWidth(pixelWidth_),
22 				pixelHeight(pixelHeight_),
23 				advanceXAdjustment(advanceXAdjustment_),
24 				rangeMin(rangeMin_),
25 				rangeMax(rangeMax_) {}
26 
27 			// WARNING: these values shall not be changed
28 			std::string fontFile;
29 			int pixelWidth;
30 			int pixelHeight;
31 			float advanceXAdjustment;
32 			Uint32 rangeMin;
33 			Uint32 rangeMax;
34 
35 			bool operator<(const Face &o) const
36 			{
37 				if (pixelWidth < o.pixelWidth) return true;
38 				if (pixelHeight < o.pixelHeight) return true;
39 				if (fontFile < o.fontFile) return true;
40 				return false;
41 			}
42 		};
43 
GetName()44 		const std::string &GetName() const { return m_name; }
IsOutline()45 		bool IsOutline() const { return m_outline; }
46 
47 		const Face &GetFaceForCodePoint(Uint32 cp);
48 
49 	private:
50 		std::string m_name;
51 		bool m_outline;
52 		std::vector<Face> m_faces;
53 	};
54 
55 } // namespace Text
56 
57 #endif
58