Changeset 7430 in orxonox.OLD for trunk/src/lib/graphics/text_engine
- Timestamp:
- Apr 29, 2006, 1:32:49 AM (19 years ago)
- Location:
- trunk/src/lib/graphics/text_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/font.cc
r7429 r7430 361 361 362 362 /** 363 * @param character The character to get info about. 363 * @param glyph: The Glyph to set the Parameters to. 364 * @param character: The character to get info about. 364 365 * @returns a Glyph struct of a character. This Glyph is a pointer, 365 and MUST be deleted by the user.. 366 367 This only works for horizontal fonts. see 368 http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html 369 for more info about vertical Fonts 370 */ 371 Glyph* Font::getGlyphMetrics(Uint16 character) 372 { 373 Glyph* rg = new Glyph; 374 rg->character = character; 366 * and MUST be deleted by the user.. 367 * 368 * This only works for horizontal fonts. see 369 * http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html 370 * for more info about vertical Fonts 371 */ 372 bool Font::getGlyphMetrics(Glyph* glyph, Uint16 character) 373 { 374 glyph->character = character; 375 375 if (likely (this->fontTTF!= NULL)) 376 376 { 377 377 int miX, maX, miY, maY, adv; 378 TTF_GlyphMetrics(this->fontTTF, rg->character,378 if (TTF_GlyphMetrics(this->fontTTF, glyph->character, 379 379 &miX, &maX, 380 380 &miY, &maY, 381 &adv); 382 printf("%c:: %d %d %d %d %d\n", rg->character, miX, maX, miY, maY, adv); 383 rg->minX = (float)miX / (float)this->renderSize; 384 rg->maxX = (float)maX / (float)this->renderSize; 385 rg->minY = (float)miY / (float)this->renderSize; 386 rg->maxY = (float)maY / (float)this->renderSize; 387 rg->advance = (float)adv / (float)this->renderSize; 388 } 389 rg->height = rg->maxY - rg->minY; 390 rg->width = rg->maxX - rg->minX; 391 rg->bearingX = (rg->advance - rg->width) / 2; 392 rg->bearingY = rg->maxY; 393 return rg; 381 &adv) == -1) 382 return false; 383 384 glyph->minX = (float)miX / (float)this->renderSize; 385 glyph->maxX = (float)maX / (float)this->renderSize; 386 glyph->minY = (float)miY / (float)this->renderSize; 387 glyph->maxY = (float)maY / (float)this->renderSize; 388 glyph->advance = (float)adv / (float)this->renderSize; 389 390 // Calculate the Rest. 391 glyph->height = glyph->maxY - glyph->minY; 392 glyph->width = glyph->maxX - glyph->minX; 393 glyph->bearingX = (glyph->advance - glyph->width) / 2; 394 glyph->bearingY = glyph->maxY; 395 return true; 396 } 397 return false; 394 398 } 395 399 … … 478 482 SDL_FreeSurface(glyphSurf); 479 483 tmpRect.x += glyphSurf->w+1; //(int)(tmpGlyph->advance * this->renderSize); 480 481 /*482 // Outputting Glyphs to BMP-files.483 char outname[1024];484 if (i < 10)485 sprintf( outname, "%s-glyph-00%d.bmp", this->getName(), i );486 else if (i <100)487 sprintf( outname, "%s-glyph-0%d.bmp", this->getName(), i );488 else489 sprintf( outname, "%s-glyph-%d.bmp", this->getName(), i );490 SDL_SaveBMP(tmpSurf, outname);*/491 484 } 492 485 } 493 486 } 494 487 // outputting the GLYPH-table 495 char outName[1024];496 sprintf( outName, "%s-glyphs.bmp", this->getName());497 SDL_SaveBMP(tmpSurf, outName);488 // char outName[1024]; 489 // sprintf( outName, "%s-glyphs.bmp", this->getName()); 490 // SDL_SaveBMP(tmpSurf, outName); 498 491 499 492 if (this->setSurface(tmpSurf)) … … 523 516 { 524 517 // setting up all the Glyphs we like. 525 glyphArray[i] = getGlyphMetrics(i); 518 Glyph* newGlyph = new Glyph; 519 if (getGlyphMetrics(newGlyph, i)) 520 glyphArray[i] = newGlyph; 521 else 522 { 523 delete newGlyph; 524 glyphArray[i] = NULL; 525 } 526 526 } 527 527 return; -
trunk/src/lib/graphics/text_engine/font.h
r7428 r7430 85 85 int getMaxAscent() const; 86 86 int getMaxDescent() const; 87 Glyph* getGlyphMetrics(Uint16 character);87 bool getGlyphMetrics(Glyph* glyph, Uint16 character); 88 88 89 89 bool createFastTexture();
Note: See TracChangeset
for help on using the changeset viewer.