@Override
  public int getSize(
      Paint paint,
      CharSequence text,
      int start,
      int end,
      @Nullable Paint.FontMetricsInt fontMetrics) {
    updateBounds();
    if (fontMetrics == null) {
      return mWidth;
    }

    return calculateLineWidthAndFontHeight(fontMetrics);
  }
A helper function to allow dropping in BetterImageSpan as a replacement to ImageSpan, and
allowing for center alignment if passed in.
fbcore/src/main/java/com/facebook/widget/text/span/BetterImageSpan.java