------------------------------------------------------------------------------
| 698 | |
| 699 | //------------------------------------------------------------------------------ |
| 700 | int vtkContext2D::ComputeFontSizeForBoundedString( |
| 701 | const vtkStdString& string, float width, float height) |
| 702 | { |
| 703 | double orientation = this->GetTextProp()->GetOrientation(); |
| 704 | this->GetTextProp()->SetOrientation(0.0); |
| 705 | |
| 706 | float stringBounds[4]; |
| 707 | int currentFontSize = this->GetTextProp()->GetFontSize(); |
| 708 | this->ComputeStringBounds(string, stringBounds); |
| 709 | |
| 710 | // font size is too big |
| 711 | if (stringBounds[2] > width || stringBounds[3] > height) |
| 712 | { |
| 713 | while (stringBounds[2] > width || stringBounds[3] > height) |
| 714 | { |
| 715 | --currentFontSize; |
| 716 | this->GetTextProp()->SetFontSize(currentFontSize); |
| 717 | this->ComputeStringBounds(string, stringBounds); |
| 718 | if (currentFontSize < 0) |
| 719 | { |
| 720 | this->GetTextProp()->SetFontSize(0); |
| 721 | return 0; |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | // font size is too small |
| 727 | else |
| 728 | { |
| 729 | while (stringBounds[2] < width && stringBounds[3] < height) |
| 730 | { |
| 731 | ++currentFontSize; |
| 732 | this->GetTextProp()->SetFontSize(currentFontSize); |
| 733 | this->ComputeStringBounds(string, stringBounds); |
| 734 | } |
| 735 | --currentFontSize; |
| 736 | this->GetTextProp()->SetFontSize(currentFontSize); |
| 737 | } |
| 738 | |
| 739 | this->GetTextProp()->SetOrientation(orientation); |
| 740 | return currentFontSize; |
| 741 | } |
| 742 | |
| 743 | //------------------------------------------------------------------------------ |
| 744 | void vtkContext2D::DrawMathTextString(vtkPoints2D* point, const vtkStdString& string) |
no test coverage detected