diff libinterp/interpfcn/graphics.cc @ 16855:359ac80ecb30

Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344) * libinterp/interp-core/gl-render.cc(render_ticktexts): Trim spaces from labels. Use % operator to repeat labels as necessary to fill number of ticks. * libinterp/interpfcn/graphics.cc(get_ticklabel_extents): Trim spaces from labels before calculating extent of text.
author Rik <rik@octave.org>
date Wed, 26 Jun 2013 15:49:57 -0700
parents 563f8f0a7e29
children
line wrap: on
line diff
--- a/libinterp/interpfcn/graphics.cc	Wed Jun 26 14:29:15 2013 -0700
+++ b/libinterp/interpfcn/graphics.cc	Wed Jun 26 15:49:57 2013 -0700
@@ -6348,13 +6348,16 @@
       double val = ticks(i);
       if (limits(0) <= val && val <= limits(1))
         {
+          std::string label (ticklabels(i));
+          label.erase (0, label.find_first_not_of (" "));
+          label = label.substr (0, label.find_last_not_of (" ")+1);
 #ifdef HAVE_FREETYPE
-          ext = text_renderer.get_extent (ticklabels(i));
+          ext = text_renderer.get_extent (label);
           wmax = std::max (wmax, ext(0));
           hmax = std::max (hmax, ext(1));
 #else
-          //FIXME: find a better approximation
-          int len = ticklabels(i).length ();
+          // FIXME: find a better approximation
+          int len = label.length ();
           wmax = std::max (wmax, 0.5*fontsize*len);
           hmax = fontsize;
 #endif