| 504 | } |
| 505 | |
| 506 | void PrintCenterJustifiedText() const |
| 507 | { |
| 508 | HPDF_REAL currentOffset = 0; // for centering |
| 509 | for (size_t i = 0; i < this->Lines.size(); ++i) |
| 510 | { |
| 511 | const Line& line = this->Lines[i]; |
| 512 | |
| 513 | if (i == 0) |
| 514 | { // Center the first line: |
| 515 | currentOffset = (this->BBoxWidth - line.Width) * 0.5f; |
| 516 | HPDF_Page_MoveTextPos(this->Page, currentOffset, 0); |
| 517 | } |
| 518 | else |
| 519 | { |
| 520 | // This line's offset: |
| 521 | HPDF_REAL lineOffset = (this->BBoxWidth - line.Width) * 0.5; |
| 522 | |
| 523 | // The incremental change to effect this lines offset relative to the |
| 524 | // current offset: |
| 525 | HPDF_REAL incrOffset = lineOffset - currentOffset; |
| 526 | |
| 527 | // Center current line and advance to new line: |
| 528 | HPDF_Page_MoveTextPos(this->Page, incrOffset, -this->Leading); |
| 529 | |
| 530 | // Update for next iteration: |
| 531 | currentOffset = lineOffset; |
| 532 | } |
| 533 | |
| 534 | HPDF_Page_ShowText(this->Page, line.String.c_str()); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | void PrintRightJustifiedText() const |
| 539 | { |
no test coverage detected