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

Method PrintCenterJustifiedText

IO/ExportPDF/vtkPDFContextDevice2D.cxx:506–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

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