MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
font.h
1 //© Copyright 2010 - 2013 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  //typedef std::vector<Glyph*> GlyphContainer;
59  typedef std::map<UInt32,Glyph*> GlyphContainer;
60  typedef GlyphContainer::iterator GlyphIterator;
61  typedef GlyphContainer::const_iterator ConstGlyphIterator;
62  protected:
63  /// @internal
64  /// @brief Container storing all the Glyphs contained in this font.
65  GlyphContainer Glyphs;
66  /// @internal
67  /// @brief The name of this font.
69  /// @internal
70  /// @brief The Atlas that this GlyphData belongs to.
72  /// @internal
73  /// @brief The width in pixels of a space in this font.
75  /// @internal
76  /// @brief The height of a line of text in this font.
78  /// @internal
79  /// @brief The height of the largest glyph in this font.
81  /// @internal
82  /// @brief I don't know.
84 
85  /// @brief Sets the dummy coordinates for a generated whitespace glyph.
86  void SetWhitespaceAtlasCoords(Glyph* Whitespace);
87  /// @brief Generates Whitespace Glyphs from this font's data for this font.
88  void GenerateWhitespaceGlyphs();
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
152  void _AddGlyph(Glyph* NewGlyph);
153  };//FontData
154  }//UI
155 }//Mezzanine
156 
157 #endif