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

Kathleen S. Biagas biagas2 at llnl.gov
Thu Mar 21 13:27:54 EDT 2013


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?

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;
     }




More information about the vtk-developers mailing list