@Override
    public Rectangle getCharacterBounds(int offset) {
      // Since we report the very end of the document as being 1 character past the document
      // length, we need to validate the offset passed back by the screen reader.
      if (offset < 0 || offset > editor.getDocument().getTextLength() - 1) {
        return null;
      }
      LogicalPosition pos = editor.offsetToLogicalPosition(offset);
      Point point = editor.logicalPositionToXY(pos);
      FontMetrics fontMetrics = editor.getFontMetrics(Font.PLAIN);
      char c = editor.getDocument().getCharsSequence().subSequence(offset, offset + 1).charAt(0);
      return new Rectangle(point.x, point.y, fontMetrics.charWidth(c), fontMetrics.getHeight());
    }
@Override
    public Rectangle getCharacterBounds(int offset)