* Draws all the characters in the text with a really * nasty complex gritty text rendering algorithm logic stuff. */
| 518 | * nasty complex gritty text rendering algorithm logic stuff. |
| 519 | */ |
| 520 | void Text::draw() |
| 521 | { |
| 522 | Surface::draw(); |
| 523 | if (_text.empty() || _font == 0) |
| 524 | { |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | // Show text borders for debugging |
| 529 | if (Options::debugUi) |
| 530 | { |
| 531 | SDL_Rect r; |
| 532 | r.w = getWidth(); |
| 533 | r.h = getHeight(); |
| 534 | r.x = 0; |
| 535 | r.y = 0; |
| 536 | this->drawRect(&r, 5); |
| 537 | r.w-=2; |
| 538 | r.h-=2; |
| 539 | r.x++; |
| 540 | r.y++; |
| 541 | this->drawRect(&r, 0); |
| 542 | } |
| 543 | |
| 544 | int x = 0, y = 0, line = 0, height = 0; |
| 545 | Font *font = _font; |
| 546 | int color = _color; |
| 547 | std::wstring *s = &_text; |
| 548 | |
| 549 | for (std::vector<int>::iterator i = _lineHeight.begin(); i != _lineHeight.end(); ++i) |
| 550 | { |
| 551 | height += *i; |
| 552 | } |
| 553 | |
| 554 | switch (_valign) |
| 555 | { |
| 556 | case ALIGN_TOP: |
| 557 | y = 0; |
| 558 | break; |
| 559 | case ALIGN_MIDDLE: |
| 560 | y = (int)ceil((getHeight() - height) / 2.0); |
| 561 | break; |
| 562 | case ALIGN_BOTTOM: |
| 563 | y = getHeight() - height; |
| 564 | break; |
| 565 | } |
| 566 | |
| 567 | x = getLineX(line); |
| 568 | |
| 569 | if (_wrap) |
| 570 | { |
| 571 | s = &_wrappedText; |
| 572 | } |
| 573 | |
| 574 | // Set up text color |
| 575 | int mul = 1; |
| 576 | if (_contrast) |
| 577 | { |
nothing calls this directly
no test coverage detected