- Timestamp:
- Aug 25, 2005, 2:46:34 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/graphics_engine.cc
r5122 r5124 466 466 this->geTextCFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 467 467 this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT); 468 this->geTextCFPS->setAbsCoor2D(5, 5);468 this->geTextCFPS->setAbsCoor2D(5, 15); 469 469 } 470 470 if (this->geTextMaxFPS == NULL) … … 472 472 this->geTextMaxFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 473 473 this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT); 474 this->geTextMaxFPS->setAbsCoor2D(5, 35);474 this->geTextMaxFPS->setAbsCoor2D(5, 40); 475 475 } 476 476 if (this->geTextMinFPS == NULL) -
trunk/src/lib/graphics/text_engine.cc
r5123 r5124 375 375 this->setSize(fontSize); 376 376 377 this-> setFont(fontFile);377 this->loadFont(fontFile); 378 378 379 379 this->setStyle("c");//TTF_STYLE_NORMAL); … … 383 383 384 384 /** 385 * destructs a font 385 * destructs a font 386 * this releases the memory a font uses to be opened. 386 387 */ 387 388 Font::~Font() … … 407 408 * @returns true if loaded, false if something went wrong, or if a font was loaded before. 408 409 */ 409 bool Font:: setFont(const char* fontFile)410 bool Font::loadFont(const char* fontFile) 410 411 { 411 412 if (!this->fontFile) … … 576 577 maxLineHeight = tmpGlyph->height; 577 578 578 if (tmpRect.x+tmpGlyph-> width> tmpSurf->w)579 if (tmpRect.x+tmpGlyph->advance > tmpSurf->w) 579 580 { 580 581 tmpRect.x = 0; … … 600 601 TexCoord tmpTexCoord; 601 602 tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w; 602 tmpTexCoord.maxU = (float)(tmpRect.x + 1 + tmpGlyph->width)/(float)tmpSurf->w;603 tmpTexCoord.maxU = (float)(tmpRect.x + tmpGlyph->advance)/(float)tmpSurf->w; 603 604 tmpTexCoord.minV = (float)(tmpRect.y)/(float)tmpSurf->w; 604 605 tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w; … … 608 609 glBegin(GL_QUADS); 609 610 glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV); 610 glVertex2d(0, 0);611 glVertex2d(0, - tmpGlyph->bearingY); 611 612 glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV); 612 glVertex2d(0, tmpGlyph->height );613 glVertex2d(0, tmpGlyph->height - tmpGlyph->bearingY); 613 614 glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV); 614 glVertex2d(tmpGlyph->width, tmpGlyph->height );615 glVertex2d(tmpGlyph->width, tmpGlyph->height - tmpGlyph->bearingY); 615 616 glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV); 616 glVertex2d(tmpGlyph->width, 0);617 glVertex2d(tmpGlyph->width, - tmpGlyph->bearingY); 617 618 glEnd(); 618 619 glEndList(); 619 620 SDL_FreeSurface(glyphSurf); 620 621 621 tmpRect.x += tmpGlyph-> width + 2;622 tmpRect.x += tmpGlyph->advance; 622 623 623 624 // Outputting Glyphs to BMP-files. … … 693 694 int i; 694 695 int x,y; // the counters 695 int maxLineHeight ;696 int maxLineHeight = this->getMaxHeight(); 696 697 unsigned int size = 32; // starting Value, we have to start somewhere 32 seems reasonable. (take any small enough 2^i number) 697 698 bool sizeOK = false; … … 701 702 { 702 703 x = 0; y = 0; 703 maxLineHeight = 0;704 704 for (i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++) 705 705 { … … 710 710 maxLineHeight = tmpGlyph->height; 711 711 712 if (x + tmpGlyph-> width> size)712 if (x + tmpGlyph->advance > size) 713 713 { 714 714 x = 0; … … 718 718 if (y + maxLineHeight + 1 > size) 719 719 break; 720 x += tmpGlyph-> width + 1;720 x += tmpGlyph->advance; 721 721 722 722 } … … 727 727 size *= 2; 728 728 } 729 return size;729 return size; 730 730 } 731 731 -
trunk/src/lib/graphics/text_engine.h
r5123 r5124 158 158 159 159 // font 160 bool setFont(const char* fontFile);160 bool loadFont(const char* fontFile); 161 161 void setSize(unsigned int fontSize); 162 162 void setStyle(const char* renderStyle); … … 165 165 inline Glyph** getGlyphArray() const { return glyphArray; }; 166 166 /** @returns the texture to the fast-texture */ 167 inline GLuint getFastTextureID() const { return fastTextureID;}167 inline GLuint getFastTextureID() const { return fastTextureID; }; 168 168 169 169 private: -
trunk/src/util/shell.cc
r5123 r5124 163 163 this->inputLineText->setText(NULL); 164 164 this->inputLineText->setParent2D(this); 165 this->inputLineText->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize );165 this->inputLineText->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize); 166 166 167 167 this->setBufferDisplaySize(this->bufferDisplaySize); … … 746 746 Vector Shell::calculateLinePosition(unsigned int lineNumber) 747 747 { 748 return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1) , 0);748 return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1) + this->textSize, 0); 749 749 } 750 750
Note: See TracChangeset
for help on using the changeset viewer.