Changeset 5124 in orxonox.OLD for trunk/src/lib/graphics/text_engine.cc
- Timestamp:
- Aug 25, 2005, 2:46:34 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.