------------------------------------------------------------------------------
| 1377 | |
| 1378 | //------------------------------------------------------------------------------ |
| 1379 | void vtkSVGContextDevice2D::ComputeStringBounds(const vtkStdString& string, float bounds[4]) |
| 1380 | { |
| 1381 | vtkTextRenderer* tren = vtkTextRenderer::GetInstance(); |
| 1382 | if (!tren) |
| 1383 | { |
| 1384 | vtkErrorMacro("vtkTextRenderer unavailable. Link to vtkRenderingFreeType " |
| 1385 | "to get the default implementation."); |
| 1386 | std::fill(bounds, bounds + 4, 0.f); |
| 1387 | return; |
| 1388 | } |
| 1389 | |
| 1390 | assert(this->Viewport && this->Viewport->GetVTKWindow()); |
| 1391 | int dpi = this->Viewport->GetVTKWindow()->GetDPI(); |
| 1392 | |
| 1393 | vtkTextRenderer::Metrics m; |
| 1394 | if (!tren->GetMetrics(this->TextProp, string, m, dpi)) |
| 1395 | { |
| 1396 | vtkErrorMacro("Error computing bbox for string '" << string << "'."); |
| 1397 | std::fill(bounds, bounds + 4, 0.f); |
| 1398 | return; |
| 1399 | } |
| 1400 | |
| 1401 | bounds[0] = 0.f; |
| 1402 | bounds[1] = 0.f; |
| 1403 | bounds[2] = static_cast<float>(m.BoundingBox[1] - m.BoundingBox[0] + 1); |
| 1404 | bounds[3] = static_cast<float>(m.BoundingBox[3] - m.BoundingBox[2] + 1); |
| 1405 | } |
| 1406 | |
| 1407 | //------------------------------------------------------------------------------ |
| 1408 | void vtkSVGContextDevice2D::ComputeJustifiedStringBounds(const char* string, float bounds[4]) |