| 536 | } |
| 537 | |
| 538 | void PrintRightJustifiedText() const |
| 539 | { |
| 540 | HPDF_REAL currentOffset = 0; // for centering |
| 541 | for (size_t i = 0; i < this->Lines.size(); ++i) |
| 542 | { |
| 543 | const Line& line = this->Lines[i]; |
| 544 | |
| 545 | if (i == 0) |
| 546 | { // Right justify the first line: |
| 547 | currentOffset = this->BBoxWidth - line.Width; |
| 548 | HPDF_Page_MoveTextPos(this->Page, currentOffset, 0); |
| 549 | } |
| 550 | else |
| 551 | { |
| 552 | // This line's offset: |
| 553 | HPDF_REAL lineOffset = this->BBoxWidth - line.Width; |
| 554 | |
| 555 | // The incremental change to effect this lines offset relative to the |
| 556 | // current offset: |
| 557 | HPDF_REAL incrOffset = lineOffset - currentOffset; |
| 558 | |
| 559 | // Center current line and advance to new line: |
| 560 | HPDF_Page_MoveTextPos(this->Page, incrOffset, -this->Leading); |
| 561 | |
| 562 | // Update for next iteration: |
| 563 | currentOffset = lineOffset; |
| 564 | } |
| 565 | |
| 566 | HPDF_Page_ShowText(this->Page, line.String.c_str()); |
| 567 | } |
| 568 | } |
| 569 | }; |
| 570 | |
| 571 | //------------------------------------------------------------------------------ |
no test coverage detected