FontFaceLayer.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROCKETCOREFONTFACELAYER_H
00029 #define ROCKETCOREFONTFACELAYER_H
00030
00031 #include <Rocket/Core/FontGlyph.h>
00032 #include <Rocket/Core/Geometry.h>
00033 #include <Rocket/Core/GeometryUtilities.h>
00034 #include <Rocket/Core/String.h>
00035 #include <Rocket/Core/Texture.h>
00036 #include "TextureLayout.h"
00037
00038 namespace Rocket {
00039 namespace Core {
00040
00041 class FontEffect;
00042 class FontFaceHandle;
00043
00051 class FontFaceLayer
00052 {
00053 public:
00054 FontFaceLayer();
00055 ~FontFaceLayer();
00056
00063 bool Initialise(const FontFaceHandle* handle, FontEffect* effect = NULL, const FontFaceLayer* clone = NULL, bool deep_clone = false);
00064
00070 bool GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id);
00076 inline void GenerateGeometry(Geometry* geometry, const word character_code, const Vector2f& position, const Colourb& colour) const
00077 {
00078 CharacterMap::const_iterator iterator = characters.find(character_code);
00079 if (iterator == characters.end())
00080 return;
00081
00082 const Character& character = (*iterator).second;
00083
00084
00085 std::vector< Vertex >& character_vertices = geometry[character.texture_index].GetVertices();
00086 std::vector< int >& character_indices = geometry[character.texture_index].GetIndices();
00087
00088 character_vertices.resize(character_vertices.size() + 4);
00089 character_indices.resize(character_indices.size() + 6);
00090 GeometryUtilities::GenerateQuad(&character_vertices[0] + (character_vertices.size() - 4), &character_indices[0] + (character_indices.size() - 6), Vector2f(position.x + character.origin.x, position.y + character.origin.y), character.dimensions, colour, character.texcoords[0], character.texcoords[1], character_vertices.size() - 4);
00091 }
00092
00095 const FontEffect* GetFontEffect() const;
00096
00100 const Texture* GetTexture(int index);
00103 int GetNumTextures() const;
00104
00107 const Colourb& GetColour() const;
00108
00109 private:
00110 struct Character
00111 {
00112
00113 Vector2f origin;
00114
00115 Vector2f dimensions;
00116
00117 Vector2f texcoords[2];
00118
00119
00120 int texture_index;
00121 };
00122
00123 typedef std::map< word, Character > CharacterMap;
00124 typedef std::vector< Texture > TextureList;
00125
00126 const FontFaceHandle* handle;
00127 FontEffect* effect;
00128
00129 TextureLayout texture_layout;
00130
00131 CharacterMap characters;
00132 TextureList textures;
00133 Colourb colour;
00134 };
00135
00136 }
00137 }
00138
00139 #endif