code: public S getStyleOfChar(int charIdx) {
          if(charIdx < 0) {
              return styles.getStyleSpan(0).getStyle();
          }
  
          Position pos = styles.offsetToPosition(charIdx, Forward);
          return styles.getStyleSpan(pos.getMajor()).getStyle();
      }
docs: Returns the style of character with the given index.
  If {@code charIdx < 0}, returns the style at the beginning of this paragraph.
  If {@code charIdx >= this.length()}, returns the style at the end of this paragraph.