Pioneer
FontConfig.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 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 {
19  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;
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 
44  const std::string &GetName() const { return m_name; }
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
Definition: FontConfig.h:13
FontConfig(const std::string &name, float scaleX=1.0f, float scaleY=1.0f)
Definition: FontConfig.cpp:11
const std::string & GetName() const
Definition: FontConfig.h:44
const Face & GetFaceForCodePoint(Uint32 cp)
Definition: FontConfig.cpp:46
bool IsOutline() const
Definition: FontConfig.h:45
Definition: DistanceFieldFont.cpp:12
Definition: FontConfig.h:18
int pixelHeight
Definition: FontConfig.h:30
bool operator<(const Face &o) const
Definition: FontConfig.h:35
Uint32 rangeMax
Definition: FontConfig.h:33
float advanceXAdjustment
Definition: FontConfig.h:31
Face(const std::string &fontFile_, int pixelWidth_, int pixelHeight_, float advanceXAdjustment_, Uint32 rangeMin_, Uint32 rangeMax_)
Definition: FontConfig.h:19
int pixelWidth
Definition: FontConfig.h:29
Uint32 rangeMin
Definition: FontConfig.h:32
std::string fontFile
Definition: FontConfig.h:28