[vtk-developers] proposed vtkTextActor patch for cut-off text.

David Lonie david.lonie at kitware.com
Fri Mar 22 09:56:47 EDT 2013


On Thu, Mar 21, 2013 at 1:27 PM, Kathleen S. Biagas <biagas2 at llnl.gov>wrote:

> I have a change to vtkTextActor.cxx that I would like to submit for
> consideration. It corrects an issue that crops up for us on some
> systems, where a portion of text is not rendered fully (top row of
> pixels appears cut-off).  I have a small test that demonstrates the
> issue (at least on my RHEL6 system).  I didn't want to submit the change
> in gerrit without understanding the procedure for providing the
> reproducer along side. Tips on that?
>

Try adding another text actor to these tests that shows the problem:

VTK/Rendering/FreeType/Testing/Cxx/TestMathTextFreeTypeTextRenderer
VTK/Rendering/FreeType/Testing/Cxx/TestMathTextFreeTypeTextRendererNoMath

and the push the test to gerrit (along with the fix).

If this is a common problem, we may want to attack the problem in the text
rendering code (rather than the actor), but let's see what we can find out.

Thanks!
Dave


> Thanks,
>
> Kathleen
>
> Here's the patch:
>
>
> --- /VTK-462c2c1/Rendering/FreeType/vtkTextActor.cxx    2013-03-20
> 07:51:43.000000000
> +++ /vtkTextActor.cxx   2013-03-18 09:41:01.000000000
> @@ -635,22 +635,27 @@
>      dims[0] = ( text_bbox[1] - text_bbox[0] + 1 );
>      dims[1] = ( text_bbox[3] - text_bbox[2] + 1 );
>
>      // compute TCoords.
>      vtkFloatArray* tc = vtkFloatArray::SafeDownCast
>        ( this->Rectangle->GetPointData()->GetTCoords() );
> +    float tcXMax, tcYMax;
> +    // Add a fudge factor to the texture coordinates to prevent the top
> +    // row of pixels from being truncated on some systems.
> +    tcXMax = fminf(1.0, (dims[0] + 0.001) /
> static_cast<float>(p2dims[0]));
> +    tcYMax = fminf(1.0, (dims[1] + 0.001) /
> static_cast<float>(p2dims[1]));
>      tc->InsertComponent(0, 0, 0.0);
>      tc->InsertComponent(0, 1, 0.0);
>
>      tc->InsertComponent(1, 0, 0.0);
> -    tc->InsertComponent(1, 1, dims[1] / static_cast<float>(p2dims[1]));
> +    tc->InsertComponent(1, 1, tcYMax);
>
> -    tc->InsertComponent(2, 0, dims[0] / static_cast<float>(p2dims[0]));
> -    tc->InsertComponent(2, 1, dims[1] / static_cast<float>(p2dims[1]));
> +    tc->InsertComponent(2, 0, tcXMax);
> +    tc->InsertComponent(2, 1, tcYMax);
>
> -    tc->InsertComponent(3, 0, dims[0] / static_cast<float>(p2dims[0]));
> +    tc->InsertComponent(3, 0, tcXMax);
>      tc->InsertComponent(3, 1, 0.0);
>      }
>    else
>      {
>      dims[0] = dims[1] = 0;
>      }
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20130322/c079fdec/attachment.html>


More information about the vtk-developers mailing list