Spinning Topp Logo BlackTopp Studios
inc
font.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _uifont_h
41 #define _uifont_h
42 
43 #include "datatypes.h"
44 
45 namespace Mezzanine
46 {
47  namespace UI
48  {
49  class Glyph;
50  class TextureAtlas;
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @brief This class represents a collection of Glyphs in a common visual style.
53  /// @details
54  ///////////////////////////////////////
56  {
57  public:
58  /// @brief Container type for Glyph storage in this class.
59  typedef std::map<UInt32,Glyph*> GlyphContainer;
60  /// @brief Iterator type for Glyphs stored by this class.
61  typedef GlyphContainer::iterator GlyphIterator;
62  /// @brief Const Iterator type for Glyphs stored by this class.
63  typedef GlyphContainer::const_iterator ConstGlyphIterator;
64  protected:
65  /// @internal
66  /// @brief Container storing all the Glyphs contained in this font.
67  GlyphContainer Glyphs;
68  /// @internal
69  /// @brief The name of this font.
71  /// @internal
72  /// @brief The Atlas that this GlyphData belongs to.
74  /// @internal
75  /// @brief The width in pixels of a space in this font.
77  /// @internal
78  /// @brief The height of a line of text in this font.
80  /// @internal
81  /// @brief The height of the largest glyph in this font.
83  /// @internal
84  /// @brief I don't know.
86 
87  /// @brief Sets the dummy coordinates for a generated whitespace glyph.
88  void SetWhitespaceAtlasCoords(Glyph* Whitespace);
89  public:
90  /// @brief Class constructor.
91  /// @param ParentAtlas The TextureAtlas this font data belongs to.
92  FontData(TextureAtlas* ParentAtlas);
93  /// @brief Class destructor.
94  ~FontData();
95 
96  ///////////////////////////////////////////////////////////////////////////////
97  // Utility Methods
98 
99  /// @brief Gets the length of a space in this font.
100  /// @return Returns a Real containing the length of a space in pixels.
101  Real GetSpaceLength() const;
102  /// @brief Gets the height of a line of text in this font.
103  /// @return Returns a Real containing the height of a line in this font in pixels.
104  Real GetLineHeight() const;
105  /// @brief Gets the height of the largest glyph in this font.
106  /// @return Returns a Real containing the height of the largest glyph in this font in pixels.
107  Real GetBaseLine() const;
108  /// @brief Gets the spacing to apply between letters in this font.
109  /// @return Returns a Real containing the amount of pixels to adjust the advance of every glyph in this font.
110  Real GetLetterSpacing() const;
111  /// @brief Gets the name of this font.
112  /// @return Returns a const String reference containing the name of this font.
113  const String& GetName() const;
114  /// @brief Gets the TextureAtlas this font belongs to.
115  /// @return Returns a pointer to the TextureAtlas this font belongs to.
116  TextureAtlas* GetAtlas() const;
117  /// @brief Gets the name of the TextureAtlas this font belongs to.
118  /// @return Returns a const String reference containing the name of the TextureAtlas this font belongs to.
119  const String& GetAtlasName() const;
120  /// @brief Gets the glyph corresponding to the provided characters UTF-8 code.
121  /// @param GlyphID The UTF-8 code for the glyph desired.
122  /// @return Returns a pointer to the requested Glyph, or NULL if it doesn't exist.
123  Glyph* GetGlyph(const UInt32& GlyphID) const;
124 
125  ///////////////////////////////////////////////////////////////////////////////
126  // Internal Methods
127 
128  /// @internal
129  /// @brief Sets the length of a space for this font.
130  /// @param SL The length of a space in pixels.
131  void _SetSpaceLength(const Real SL);
132  /// @internal
133  /// @brief Sets the height of a single line of text in this font.
134  /// @param LH The height of a line of text in this font in pixels.
135  void _SetLineHeight(const Real LH);
136  /// @internal
137  /// @brief Sets the height of the largest glyph in this font.
138  /// @param BL The maximum height of a glyph in this font in pixels.
139  void _SetBaseLine(const Real BL);
140  /// @internal
141  /// @brief Sets the LetterSpacing of this font.
142  /// @param LS The value to be set for this fonts LetterSpacing.
143  void _SetLetterSpacing(const Real LS);
144  /// @internal
145  /// @brief Sets the name of this font.
146  /// @param Name The name to be given to this font.
147  void _SetName(const String& Name);
148  /// @internal
149  /// @brief Adds a new glyph to this Font.
150  /// @exception An exception will be thrown if a glyph with the same ID is already taken.
151  /// @param NewGlyph A pointer to the new glyph to be added.
152  void _AddGlyph(Glyph* NewGlyph);
153  /// @brief Generates Whitespace Glyphs from this font's data for this font.
154  void _GenerateWhitespaceGlyphs();
155  };//FontData
156  }//UI
157 }//Mezzanine
158 
159 #endif
std::map< UInt32, Glyph * > GlyphContainer
Container type for Glyph storage in this class.
Definition: font.h:59
This class represents a collection of Glyphs in a common visual style.
Definition: font.h:55
Class used to describe a single glyph or character available for text operations. ...
Definition: glyph.h:59
All the definitions for datatypes as well as some basic conversion functions are defined here...
GlyphContainer::iterator GlyphIterator
Iterator type for Glyphs stored by this class.
Definition: font.h:61
Real SpaceLength
The width in pixels of a space in this font.
Definition: font.h:76
This is a collection of smaller textures packed into a larger texture, intended to increase UI perfor...
Definition: textureatlas.h:71
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
Real BaseLine
The height of the largest glyph in this font.
Definition: font.h:82
GlyphContainer::const_iterator ConstGlyphIterator
Const Iterator type for Glyphs stored by this class.
Definition: font.h:63
Real LetterSpacing
I don't know.
Definition: font.h:85
GlyphContainer Glyphs
Container storing all the Glyphs contained in this font.
Definition: font.h:67
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
String FontName
The name of this font.
Definition: font.h:70
TextureAtlas * Atlas
The Atlas that this GlyphData belongs to.
Definition: font.h:73
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
Real LineHeight
The height of a line of text in this font.
Definition: font.h:79