code: protected double getWidth (Rectangle2D laybounds)
      {
          double width = Math.max(laybounds.getX(), 0) + laybounds.getWidth();
          if ((_style & OUTLINE) != 0) {
              width += 2;
          } else if ((_style & SHADOW) != 0) {
              width += 1;
          } else if ((_style & BOLD) != 0) {
              width += 1;
          }
          return width;
      }
docs: Computes the total width of a {@link TextLayout} given bounds returned from a call to {@link
  TextLayout#getBounds}.