[mapguide-commits] r4573 - trunk/MgDev/Common/Renderers

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Feb 1 16:31:10 EST 2010


Author: waltweltonlair
Date: 2010-02-01 16:31:09 -0500 (Mon, 01 Feb 2010)
New Revision: 4573

Modified:
   trunk/MgDev/Common/Renderers/AGGRenderer.cpp
Log:
Fix #1261 (AGG renderer does not account for spaces at end of strings when measuring width)

The code in AGGRenderer::MeasureString was not adjusting the right edge of the string bounds
for spaces.  For spaces in the middle of the string this doesn't matter - the bounds will get
adjusted once a non-space character is encountered.  But if the final character is a space then
the right edge of the bounds will not include the width of the space.

For spaces the glyph bounds are flagged as invalid, and so the code was not adjusting the
right/top/bottom edges of the measured bounds.  But the glyph bounds are only used to adjust
the top/bottom edges.  The right side adjustment is done using the glyph's advance_x property,
and this property is valid for all characters.


Modified: trunk/MgDev/Common/Renderers/AGGRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/AGGRenderer.cpp	2010-02-01 21:15:33 UTC (rev 4572)
+++ trunk/MgDev/Common/Renderers/AGGRenderer.cpp	2010-02-01 21:31:09 UTC (rev 4573)
@@ -1687,10 +1687,14 @@
         xpos += glyph->advance_x;
         ypos += glyph->advance_y;
 
+        // don't include this inside the is_valid check - spaces have
+        // is_valid false, yet we still need to adjust the right edge
+        // of the bounds to account for them
+        if (xpos > right)
+            right = xpos;
+
         if (glyph->bounds.is_valid())
         {
-            if (xpos > right)
-                right = xpos;
             if (top < glyph->bounds.y2)
                 top = glyph->bounds.y2;
             if (bottom > glyph->bounds.y1)



More information about the mapguide-commits mailing list