- Timestamp:
- Jun 23, 2006, 6:58:01 PM (18 years ago)
- Location:
- branches/fontdata/src/lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fontdata/src/lib/graphics/text_engine/font.cc
r8753 r8754 29 29 #include "compiler.h" 30 30 31 32 Font::Font() 33 : data(Font::defaultFontData) 34 { 35 this->init(); 36 37 } 31 38 32 39 /** … … 149 156 bool Font::loadFontFromSDL_Surface(SDL_Surface* surface) 150 157 { 158 this->data = FontDataPointer (new FontData()); 151 159 // loading to a texture. 152 160 if(surface == NULL) … … 286 294 FontDataPointer Font::initDefaultFont() 287 295 { 296 Font::defaultFontData = FontDataPointer(new FontData); 288 297 return Font(font_xpm).data; 289 298 } -
branches/fontdata/src/lib/graphics/text_engine/font.h
r8753 r8754 21 21 22 22 public: 23 Font(); 23 24 Font(const std::string& fontFile, 24 25 unsigned int renderSize); … … 26 27 Font(char** xpmArray); 27 28 virtual ~Font(); 29 30 Font& operator=(const Font& font) { this->data = font.data; return *this; }; 31 bool operator==(const Font& font) const { return this->data == font.data; }; 28 32 29 33 // font -
branches/fontdata/src/lib/graphics/text_engine/limited_width_text.cc
r8619 r8754 81 81 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 82 82 83 glBindTexture(GL_TEXTURE_2D, this->font() ->getTexture());83 glBindTexture(GL_TEXTURE_2D, this->font().getTexture()); 84 84 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 85 85 glRotatef(this->getAbsDir2D(), 0, 0, 1); … … 90 90 for (unsigned int i = 0; i < this->_dotedText.size(); i++) 91 91 { 92 if(likely((tmpGlyph = this->font() ->getGlyphArray()[this->_dotedText[i]]) != NULL))92 if(likely((tmpGlyph = this->font().getGlyphArray()[this->_dotedText[i]]) != NULL)) 93 93 { 94 94 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); … … 118 118 void LimitedWidthText::setupTextWidth() 119 119 { 120 float dotsSize = this->font() ->getGlyphArray()[46]->advance * 3.0;120 float dotsSize = this->font().getGlyphArray()[46]->advance * 3.0; 121 121 122 122 float width = 0.0f; … … 134 134 this->_dotedText = this->text().substr(0, i) + "..."; 135 135 if (i > 0) 136 width -= this->font() ->getGlyphArray()[this->text()[i-1]]->advance;136 width -= this->font().getGlyphArray()[this->text()[i-1]]->advance; 137 137 width += dotsSize; 138 138 break; 139 139 } 140 140 // Advance the Text. 141 if(this->font() ->getGlyphArray()[this->text()[i]] != NULL)142 width += this->font() ->getGlyphArray()[this->text()[i]]->advance;141 if(this->font().getGlyphArray()[this->text()[i]] != NULL) 142 width += this->font().getGlyphArray()[this->text()[i]]->advance; 143 143 } 144 144 break; … … 152 152 this->_dotedText = std::string("...") + this->text().substr(i); 153 153 if (i + 1 < (int)text().size() ) 154 width -= this->font() ->getGlyphArray()[this->text()[i+1]]->advance;154 width -= this->font().getGlyphArray()[this->text()[i+1]]->advance; 155 155 width += dotsSize; 156 156 break; 157 157 } 158 158 // Advance the Text. 159 if(this->font() ->getGlyphArray()[this->text()[i]] != NULL)160 width += this->font() ->getGlyphArray()[this->text()[i]]->advance;159 if(this->font().getGlyphArray()[this->text()[i]] != NULL) 160 width += this->font().getGlyphArray()[this->text()[i]]->advance; 161 161 } 162 162 break; -
branches/fontdata/src/lib/graphics/text_engine/multi_line_text.cc
r8619 r8754 82 82 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 83 83 84 glBindTexture(GL_TEXTURE_2D, this->font() ->getTexture());84 glBindTexture(GL_TEXTURE_2D, this->font().getTexture()); 85 85 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 86 86 glRotatef(this->getAbsDir2D(), 0, 0, 1); … … 99 99 ++lineNumber; 100 100 posX = 0.0f; 101 posY += this->lineSpacing + this->size(); //this->font() ->getMaxHeight();101 posY += this->lineSpacing + this->size(); //this->font().getMaxHeight(); 102 102 } 103 103 104 if(likely((tmpGlyph = this->font() ->getGlyphArray()[this->text()[i]]) != NULL))104 if(likely((tmpGlyph = this->font().getGlyphArray()[this->text()[i]]) != NULL)) 105 105 { 106 106 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); … … 141 141 { 142 142 this->lineEnds.push_back( i -1 ); 143 width = this->font() ->getGlyphArray()[this->text()[i-1]]->advance;143 width = this->font().getGlyphArray()[this->text()[i-1]]->advance; 144 144 } 145 145 else … … 148 148 149 149 // Advance the Text. 150 if(this->font() ->getGlyphArray()[this->text()[i]] != NULL)151 width += this->font() ->getGlyphArray()[this->text()[i]]->advance;150 if(this->font().getGlyphArray()[this->text()[i]] != NULL) 151 width += this->font().getGlyphArray()[this->text()[i]]->advance; 152 152 } 153 153 this->lineCount = lineEnds.size() + 1; 154 this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font() ->getMaxHeight()));154 this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font().getMaxHeight())); 155 155 } 156 156 -
branches/fontdata/src/lib/graphics/text_engine/text.cc
r8753 r8754 28 28 */ 29 29 Text::Text(const std::string& fontFile, unsigned int textSize) 30 : _font(fontFile, FONT_DEFAULT_RENDER_SIZE) 30 31 { 31 32 this->setClassID(CL_TEXT, "Text"); … … 38 39 39 40 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); 40 41 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);42 41 } 43 42 44 43 Text::Text(const Text& text) 44 : _font() 45 45 { 46 46 this->setClassID(CL_TEXT, "Text"); 47 this->_font = NULL;48 47 49 48 *this = text; … … 93 92 this->_color = text._color; 94 93 this->setAlignment(text.getAlignment()); 95 if (this->_font != NULL) 96 ResourceManager::getInstance()->unload(this->_font); 97 98 this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK 94 95 this->_font = text._font; 99 96 100 97 this->_text = text._text; … … 192 189 193 190 // unloading the Font if we alrady have one loaded. 194 this->_font = newFont;191 this->_font = *newFont; 195 192 // if (oldFont != NULL && oldFont != Font::getDefaultFont()) 196 193 // ResourceManager::getInstance()->unload(oldFont); … … 238 235 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 239 236 240 glBindTexture(GL_TEXTURE_2D, this->_font ->getTexture());237 glBindTexture(GL_TEXTURE_2D, this->_font.getTexture()); 241 238 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 242 239 glRotatef(this->getAbsDir2D(), 0, 0, 1); … … 247 244 for (unsigned int i = 0; i < this->_text.size(); i++) 248 245 { 249 if(likely((tmpGlyph = this->font() ->getGlyphArray()[this->_text[i]]) != NULL))246 if(likely((tmpGlyph = this->font().getGlyphArray()[this->_text[i]]) != NULL)) 250 247 { 251 248 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); … … 277 274 float width = 0; 278 275 for (unsigned int i = 0; i < this->_text.size(); i++) 279 if(this->_font ->getGlyphArray()[this->_text[i]] != NULL)280 width += this->_font ->getGlyphArray()[this->_text[i]]->advance;276 if(this->_font.getGlyphArray()[this->_text[i]] != NULL) 277 width += this->_font.getGlyphArray()[this->_text[i]]->advance; 281 278 this->setSizeX2D(width * this->size()); 282 279 } … … 288 285 void Text::debug() const 289 286 { 290 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this->_font ->getName(), this->_text.c_str());287 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str()); 291 288 PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->_color.r(), this->_color.g(), this->_color.b(), this->_color.a()); 292 289 } -
branches/fontdata/src/lib/graphics/text_engine/text.h
r8619 r8754 9 9 #include "element_2d.h" 10 10 #include "color.h" 11 #include "font.h" 11 12 12 13 #define TEXT_ALIGN_LEFT E2D_ALIGN_LEFT … … 20 21 21 22 // FORWARD DECLARATION 22 class Font;23 23 struct SDL_Surface; 24 24 … … 58 58 59 59 /** @returns the pointer to the stored Font (not changeable) */ 60 inline const Font * constfont() const { return this->_font; };60 inline const Font& font() const { return this->_font; }; 61 61 /** @returns the Blending Value [0 invisible 1.0 full visible */ 62 62 inline float blending() const { return this->_color.a(); }; … … 76 76 77 77 private: 78 Font *_font; //!< Font of this text78 Font _font; //!< Font of this text 79 79 80 80 std::string _text; //!< The text to display -
branches/fontdata/src/lib/graphics/text_engine/text_engine.cc
r8753 r8754 75 75 // while (fontList->size() > 0) 76 76 { 77 Font* font = dynamic_cast<Font*>(fontList->back());77 // Font* font = dynamic_cast<Font*>(fontList->back()); 78 78 //if (likely(font != Font::getDefaultFont())) 79 79 // ResourceManager::getInstance()->unload(font, RP_GAME); -
branches/fontdata/src/lib/util/count_pointer.h
r8145 r8754 21 21 return *this; 22 22 } 23 bool operator==(const CountPointer& r) const { return this->itsCounter->ptr == r.itsCounter->ptr; }; 23 24 X& operator*() const { return *itsCounter->ptr; } 24 25 X* operator->() const { return itsCounter->ptr; }
Note: See TracChangeset
for help on using the changeset viewer.