From 9a3b037ef8621ad400eb913220021fd0e4d75e04 Mon Sep 17 00:00:00 2001 From: Dan Lipsa <dan.lipsa@kitware.com> Date: Tue, 6 Sep 2016 14:29:33 -0400 Subject: [PATCH] BUG: lastPos = firstPos + size - 1. In computing the text bounding box, the -1 in the formula was omitted. --- Rendering/Core/vtkTextMapper.cxx | 18 +++++++----------- Rendering/FreeType/vtkFreeTypeTools.cxx | 15 ++++++++++----- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Rendering/Core/vtkTextMapper.cxx b/Rendering/Core/vtkTextMapper.cxx index bb5b2b7fe7b..a16ce004d31 100644 --- a/Rendering/Core/vtkTextMapper.cxx +++ b/Rendering/Core/vtkTextMapper.cxx @@ -441,21 +441,17 @@ void vtkTextMapper::UpdateQuad(vtkActor2D *actor, int dpi) int dims[3]; this->Image->GetDimensions(dims); - // Add a fudge factor to the texture coordinates to prevent the top - // row of pixels from being truncated on some systems. The coordinates - // are calculated to be centered on a texel and trim the padding from the - // image. (padding is often added to create textures that have power-of-two - // dimensions) + // The coordinates are calculated to be centered on a texel and + // trim the padding from the image. (padding is often added to + // create textures that have power-of-two dimensions) float tw = static_cast<float>(this->TextDims[0]); float th = static_cast<float>(this->TextDims[1]); float iw = static_cast<float>(dims[0]); float ih = static_cast<float>(dims[1]); - float tcXMin = 1.f / (2.f * iw); - float tcYMin = 1.f / (2.f * ih); - float tcXMax = std::min(1.0f, - (((2.f * tw - 1.f) / (2.f)) + 0.000001f) / iw); - float tcYMax = std::min(1.0f, - (((2.f * th - 1.f) / (2.f)) + 0.000001f) / ih); + float tcXMin = 0; + float tcYMin = 0; + float tcXMax = static_cast<float>(tw) / iw; + float tcYMax = static_cast<float>(th) / ih; if (vtkFloatArray *tc = vtkArrayDownCast<vtkFloatArray>( this->PolyData->GetPointData()->GetTCoords())) diff --git a/Rendering/FreeType/vtkFreeTypeTools.cxx b/Rendering/FreeType/vtkFreeTypeTools.cxx index 4d2bc7d16e9..5e944d39449 100644 --- a/Rendering/FreeType/vtkFreeTypeTools.cxx +++ b/Rendering/FreeType/vtkFreeTypeTools.cxx @@ -1357,6 +1357,7 @@ bool vtkFreeTypeTools::RenderStringInternal(vtkTextProperty *tprop, ptr[3] = 255; } } + return true; } @@ -1509,8 +1510,12 @@ bool vtkFreeTypeTools::CalculateBoundingBox(const T& str, // The rotated padding on the text's vertical and horizontal axes: vtkVector2i hPad(pad, 0); vtkVector2i vPad(0, pad); + vtkVector2i hOne(1, 0); + vtkVector2i vOne(0, 1); rotateVector2i(hPad, s, c); rotateVector2i(vPad, s, c); + rotateVector2i(hOne, s, c); + rotateVector2i(vOne, s, c); // Calculate the bottom left corner of the data rect. Start at anchor point // (0, 0) and subtract out justification. Account for background/frame padding to @@ -1522,7 +1527,7 @@ bool vtkFreeTypeTools::CalculateBoundingBox(const T& str, metaData.BL = metaData.BL - (metaData.dx * 0.5); break; case VTK_TEXT_RIGHT: - metaData.BL = metaData.BL - metaData.dx + hPad; + metaData.BL = metaData.BL - metaData.dx + hPad + hOne; break; case VTK_TEXT_LEFT: metaData.BL = metaData.BL - hPad; @@ -1541,7 +1546,7 @@ bool vtkFreeTypeTools::CalculateBoundingBox(const T& str, metaData.BL = metaData.BL - vPad; break; case VTK_TEXT_TOP: - metaData.BL = metaData.BL - metaData.dy + vPad; + metaData.BL = metaData.BL - metaData.dy + vPad + vOne; break; default: vtkErrorMacro(<< "Bad vertical alignment flag: " @@ -1550,9 +1555,9 @@ bool vtkFreeTypeTools::CalculateBoundingBox(const T& str, } // Compute the other corners of the data: - metaData.TL = metaData.BL + metaData.dy; - metaData.TR = metaData.TL + metaData.dx; - metaData.BR = metaData.BL + metaData.dx; + metaData.TL = metaData.BL + metaData.dy - vOne; + metaData.TR = metaData.TL + metaData.dx - hOne; + metaData.BR = metaData.BL + metaData.dx - hOne; // First baseline offset from top-left corner. vtkVector2i penOffset(pad, -pad); -- GitLab