44 #include "UI/uienumerations.h"
45 #include "UI/kerning.h"
47 #include "UI/textureatlas.h"
84 Atlas(Data->GetAtlas()), Font(Data), GlyphID(0), GlyphAdvance(0), VerticalOffset(0) { }
92 Atlas(TexAtlas), Font(Data), GlyphID(ID), GlyphAdvance(Advance), VerticalOffset(VertOffset) { }
95 { this->Kernings.clear(); }
121 {
return this->Atlas->
GetName(); }
128 Whole NumKernings = this->Kernings.size();
129 if( NumKernings == 0 || Previous == 0 )
132 for(
Whole Index = 0 ; Index < NumKernings ; ++Index )
134 if( this->Kernings[Index].
Character == Previous )
135 return this->Kernings[Index].Kerning;
145 {
return (this->GlyphID == HT); }
148 {
return (this->GlyphID == LF); }
151 {
return (this->GlyphID == VT); }
154 {
return (this->GlyphID == CR); }
157 {
return (this->GlyphID == Space); }
160 {
return (this->GlyphID == NEL); }
164 {
return this->IsHorizontalTab() || this->IsVerticalTab(); }
167 {
return this->IsLineFeed() || this->IsCarriageReturn() || this->IsNextLine(); }
170 {
return this->IsTab() || this->IsNewLine() || this->IsSpace(); }
177 {
return this->AtlasCoords[UI::QC_TopLeft].
Y * this->Atlas->
GetTextureSize().
Y; }
180 {
return this->AtlasCoords[UI::QC_BottomRight].
Y * this->Atlas->
GetTextureSize().
Y; }
183 {
return this->AtlasCoords[UI::QC_TopLeft].
X * this->Atlas->
GetTextureSize().
X; }
186 {
return this->AtlasCoords[UI::QC_BottomRight].
X * this->Atlas->
GetTextureSize().
X; }
189 {
return this->GetSize().Y; }
192 {
return this->GetSize().X; }
195 {
return this->AtlasCoords[UI::QC_TopLeft] * this->Atlas->
GetTextureSize(); }
199 if( this->IsNewLine() )
return Vector2(0,0);
200 else if( this->IsSpace() || this->IsTab() )
return Vector2(this->GlyphAdvance,this->Font->
GetBaseLine());
201 else return (this->AtlasCoords[UI::QC_BottomRight] - this->AtlasCoords[UI::QC_TopLeft]) * this->Atlas->
GetTextureSize();
210 case UI::QC_TopLeft:
return this->AtlasCoords[UI::QC_TopLeft] * this->Atlas->
GetTextureSize();
break;
211 case UI::QC_TopRight:
return this->AtlasCoords[UI::QC_TopRight] * this->Atlas->
GetTextureSize();
break;
212 case UI::QC_BottomLeft:
return this->AtlasCoords[UI::QC_BottomLeft] * this->Atlas->
GetTextureSize();
break;
213 case UI::QC_BottomRight:
return this->AtlasCoords[UI::QC_BottomRight] * this->Atlas->
GetTextureSize();
break;
224 case UI::QC_TopLeft:
return this->AtlasCoords[UI::QC_TopLeft];
break;
225 case UI::QC_TopRight:
return this->AtlasCoords[UI::QC_TopRight];
break;
226 case UI::QC_BottomLeft:
return this->AtlasCoords[UI::QC_BottomLeft];
break;
227 case UI::QC_BottomRight:
return this->AtlasCoords[UI::QC_BottomRight];
break;
~Glyph()
Class destructor.
This class represents a collection of Glyphs in a common visual style.
Vector2 GetTextureSize() const
Gets the size of the TextureAtlas.
bool IsWhitespace() const
Checks if this glyph is not renderable.
Real GetUVBottom() const
Gets the Bottom coordinate on the Texture.
const String & GetName() const
Gets the name of this Texture Atlas.
const String & GetAtlasName() const
Gets the name of the atlas this glyph belongs to.
Class used to describe a single glyph or character available for text operations. ...
Real GetUVRight() const
Gets the Right coordinate on the Texture.
KerningContainer Kernings
List of all the Kernings that apply to this glyph.
Real GetWidth() const
Gets the glyphs width on the Texture.
bool IsNextLine() const
Checks if this glyph is a next line.
Vector2 GetSize() const
Gets the size of the glyph on the Texture.
QuadCorner
Used by Sprites and Glyphs for tracking their placement on a TextureAtlas.
Whitespace
This enum represents the common whitespace characters found in Ascii/UTF-8.
This is a collection of smaller textures packed into a larger texture, intended to increase UI perfor...
This implements the exception hiearchy for Mezzanine.
bool IsVerticalTab() const
Checks if this glyph is a vertical tab.
KerningContainer::iterator KerningIterator
Iterator type for Kerning information stored in this class.
Real VerticalOffset
The amount of pixels the glyph is to be adjusted on the Y axis.
Real GlyphAdvance
The number of pixels to advance the cursor for the next glyph.
float Real
A Datatype used to represent a real floating point number.
Glyph(FontData *Data)
Default constructor.
std::vector< KerningInfo > KerningContainer
Container type for Kerning information stored by this class.
Real Y
Coordinate on the Y vector.
bool IsNewLine() const
Checks if this glyph marks a new line.
FontData * Font
The collection of glyphs this glyph belongs to.
This class creates and encapsultes a character that can be used in text renders.
Real X
Coordinate on the X vector.
uint32_t UInt32
An 32-bit unsigned integer.
This is used to represent a point on a 2 dimentional area, such as a screen.
bool IsTab() const
Checks if this glyph marks a tab.
Real GetUVLeft() const
Gets the Left coordinate on the Texture.
Real GetHeight() const
Gets the glyphs height on the Texture.
TextureAtlas * Atlas
The TextureAtlas this glyph belongs to.
Real GetKerning(const UInt32 Previous) const
Convenience function for getting the Kerning information for a given Glyph.
bool IsCarriageReturn() const
Checks if this glyph is a carriage return.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Real GetBaseLine() const
Gets the height of the largest glyph in this font.
bool IsHorizontalTab() const
Checks if this glyph is a horizontal tab.
bool IsSpace() const
Checks if this glyph is a space.
bool IsLineFeed() const
Checks if this glyph is a line feed.
Vector2 GetRelativeAtlasCoords(const UI::QuadCorner Corner) const
Gets the relative position on the Atlas of a corner belonging to this glyph.
Vector2 GetPosition() const
Gets the position of the glyph on the Texture.
std::string String
A datatype used to a series of characters.
UInt32 GlyphID
The Character this glyph information represents.
KerningContainer::const_iterator ConstKerningIterator
Const Iterator type for Kerning information stored in this class.
Glyph(FontData *Data, TextureAtlas *TexAtlas, const UInt32 &ID, const Real &Advance, const Real &VertOffset)
Descriptive constructor.
Vector2 GetAtlasCoords(const UI::QuadCorner Corner) const
Gets the pixel position on the Atlas of a corner belonging to this glyph.
Real GetUVTop() const
Gets the Top coordinate on the Texture.