title: Evaluate bounds of a Path (created only with a String)
body: <p>I would like to draw a String with Path and center it inside a Rectangle. 
  The problem is that I don't know how to evaluate the size/bounds of the path.
  I have tried to use the corresponding size of the the same String drawn in a normal way (gc.drawString...) and after using gc.textExtent(String), but apparently the two size are different so the result is not ok....</p>
  
  <p>Do you have any idea how to evaluate the size of the path in order to draw it centered in a rectangle?</p>
  
  <p>The problem is that drawing a string with path is bigger that drawing a string in the normal way. You can verify it with this simple code.</p>
  
  <pre><code>import org.eclipse.swt.SWT;
  import org.eclipse.swt.SWTException;
  import org.eclipse.swt.graphics.Color;
  import org.eclipse.swt.graphics.Font;
  import org.eclipse.swt.graphics.GC;
  import org.eclipse.swt.graphics.Path;
  import org.eclipse.swt.widgets.Display;
  import org.eclipse.swt.widgets.Event;
  import org.eclipse.swt.widgets.Listener;
  import org.eclipse.swt.widgets.Shell;
  
  public class ShapeText 
  {
      static Path path=null;
      public static void main(String[] args) 
      {
          final Display display = new Display();
          Font font = new Font(display, "Times", 50, SWT.BOLD);
          final Color blue = display.getSystemColor(SWT.COLOR_BLUE);
          final Color red = display.getSystemColor(SWT.COLOR_RED);
  
          try {
  
          } catch (SWTException e) {
              System.out.println(e.getMessage());
              display.dispose();
              return;
          }
  
          Shell shell = new Shell(display);
          shell.addListener(SWT.Paint, new Listener() 
          {
              public void handleEvent(Event e) 
              {   
  
  
                  path = new Path(display);
                  e.gc.setFont(font);
                  path.addString("Path is different", 0, 0, font);
                  GC gc = e.gc;
                  gc.setAntialias(SWT.ON);
                  gc.setTextAntialias(SWT.ON);
  
                  gc.setForeground(blue);
                  gc.setBackground(blue);
                  //gc.fillPath(path);
                  gc.drawPath(path);
                  gc.setForeground(red);
                  gc.drawString("Path is different", 0, 0,true);
              }
          });
  
          shell.setSize(530,120);
  
          shell.open();
          while (!shell.isDisposed()) {
              if (!display.readAndDispatch())
                  display.sleep();
          }
  
          path.dispose();
          font.dispose();
          display.dispose();
      }
  }
  </code></pre>
  
  <p>This is the result:</p>
  
  <p><a href="https://i.stack.imgur.com/fInZj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fInZj.png" alt="enter image description here"></a></p>
  
  <p>As you can see the String drawn with Path (in blue) is longer than the other (in red)...</p>