------------------------------------------------------------------------------
| 110 | |
| 111 | //------------------------------------------------------------------------------ |
| 112 | bool vtkMathTextFreeTypeTextRenderer::GetMetricsInternal(vtkTextProperty* tprop, |
| 113 | const vtkStdString& str, vtkTextRenderer::Metrics& metrics, int dpi, int backend) |
| 114 | { |
| 115 | if (!tprop) |
| 116 | { |
| 117 | vtkErrorMacro("No text property supplied!"); |
| 118 | return false; |
| 119 | } |
| 120 | |
| 121 | metrics = Metrics(); |
| 122 | if (str.empty()) |
| 123 | { |
| 124 | return true; |
| 125 | } |
| 126 | |
| 127 | if (static_cast<Backend>(backend) == Default) |
| 128 | { |
| 129 | backend = this->DefaultBackend; |
| 130 | } |
| 131 | |
| 132 | if (static_cast<Backend>(backend) == Detect) |
| 133 | { |
| 134 | backend = this->DetectBackend(str); |
| 135 | } |
| 136 | |
| 137 | switch (static_cast<Backend>(backend)) |
| 138 | { |
| 139 | case MathText: |
| 140 | if (this->MathTextIsSupported()) |
| 141 | { |
| 142 | if (this->MathTextUtilities->GetMetrics(tprop, str.c_str(), dpi, metrics)) |
| 143 | { |
| 144 | return true; |
| 145 | } |
| 146 | } |
| 147 | vtkDebugMacro("MathText unavailable. Falling back to FreeType."); |
| 148 | [[fallthrough]]; |
| 149 | case FreeType: |
| 150 | { |
| 151 | vtkStdString cleanString(str); |
| 152 | this->CleanUpFreeTypeEscapes(cleanString); |
| 153 | // Interpret string as UTF-8, use the UTF-16 GetMetrics overload: |
| 154 | return this->FreeTypeTools->GetMetrics(tprop, cleanString, dpi, metrics); |
| 155 | } |
| 156 | case Default: |
| 157 | case UserBackend: |
| 158 | default: |
| 159 | vtkDebugMacro("Unrecognized backend requested: " << backend); |
| 160 | break; |
| 161 | case Detect: |
| 162 | vtkDebugMacro("Unhandled 'Detect' backend requested!"); |
| 163 | break; |
| 164 | } |
| 165 | return false; |
| 166 | } |
| 167 | |
| 168 | //------------------------------------------------------------------------------ |
| 169 | bool vtkMathTextFreeTypeTextRenderer::RenderStringInternal(vtkTextProperty* tprop, |
no test coverage detected