protected int getOffsetAboveBaseline(final int ascent, final int descent) {
    switch (mAlignment) {
      case ALIGN_BOTTOM:
        return descent - mHeight - mMargin.bottom;
      case ALIGN_CENTER:
        int textHeight = (descent - ascent) + mMargin.top + mMargin.bottom;
        int offset = (textHeight - mHeight) / 2;
        return ascent + offset - mMargin.bottom;
      case ALIGN_BASELINE:
      default:
        return -mHeight - mMargin.bottom;
    }
  }
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