MCPcopy Create free account
hub / github.com/Kitware/VTK / PrintRightJustifiedText

Method PrintRightJustifiedText

IO/ExportPDF/vtkPDFContextDevice2D.cxx:538–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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//------------------------------------------------------------------------------

Callers 1

DrawTextMethod · 0.95

Calls 4

HPDF_Page_MoveTextPosFunction · 0.85
HPDF_Page_ShowTextFunction · 0.85
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected