------------------------------------------------------------------------------
| 53 | |
| 54 | //------------------------------------------------------------------------------ |
| 55 | bool vtkMathTextFreeTypeTextRenderer::GetBoundingBoxInternal( |
| 56 | vtkTextProperty* tprop, const vtkStdString& str, int bbox[4], int dpi, int backend) |
| 57 | { |
| 58 | if (!bbox || !tprop) |
| 59 | { |
| 60 | vtkErrorMacro("No bounding box container and/or text property supplied!"); |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | memset(bbox, 0, 4 * sizeof(int)); |
| 65 | if (str.empty()) |
| 66 | { |
| 67 | return true; |
| 68 | } |
| 69 | |
| 70 | if (static_cast<Backend>(backend) == Default) |
| 71 | { |
| 72 | backend = this->DefaultBackend; |
| 73 | } |
| 74 | |
| 75 | if (static_cast<Backend>(backend) == Detect) |
| 76 | { |
| 77 | backend = this->DetectBackend(str); |
| 78 | } |
| 79 | |
| 80 | switch (static_cast<Backend>(backend)) |
| 81 | { |
| 82 | case MathText: |
| 83 | if (this->MathTextIsSupported()) |
| 84 | { |
| 85 | if (this->MathTextUtilities->GetBoundingBox(tprop, str.c_str(), dpi, bbox)) |
| 86 | { |
| 87 | return true; |
| 88 | } |
| 89 | } |
| 90 | vtkDebugMacro("MathText unavailable. Falling back to FreeType."); |
| 91 | [[fallthrough]]; |
| 92 | case FreeType: |
| 93 | { |
| 94 | vtkStdString cleanString(str); |
| 95 | this->CleanUpFreeTypeEscapes(cleanString); |
| 96 | // Interpret string as UTF-8, use the UTF-16 GetBoundingBox overload: |
| 97 | return this->FreeTypeTools->GetBoundingBox(tprop, cleanString, dpi, bbox); |
| 98 | } |
| 99 | case Default: |
| 100 | case UserBackend: |
| 101 | default: |
| 102 | vtkDebugMacro("Unrecognized backend requested: " << backend); |
| 103 | break; |
| 104 | case Detect: |
| 105 | vtkDebugMacro("Unhandled 'Detect' backend requested!"); |
| 106 | break; |
| 107 | } |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | //------------------------------------------------------------------------------ |
| 112 | bool vtkMathTextFreeTypeTextRenderer::GetMetricsInternal(vtkTextProperty* tprop, |
no test coverage detected