static void updateMetrics( FontMetricsInt fmi, int previousTop, int previousAscent, int previousDescent, int previousBottom, int previousLeading) { fmi.top = Math.min(fmi.top, previousTop); fmi.ascent = Math.min(fmi.ascent, previousAscent); fmi.descent = Math.max(fmi.descent, previousDescent); fmi.bottom = Math.max(fmi.bottom, previousBottom); fmi.leading = Math.max(fmi.leading, previousLeading); }
@Override public void chooseHeight( CharSequence text, int start, int end, int spanstartv, int v, FontMetricsInt fm) { // Spanned spannedText = (Spanned) text; // final int spanStart = spannedText.getSpanStart(this); if (!isVisible()) { // remove ALL height if (mHideTopPadding) { // only remove top if allowed fm.ascent = 0; fm.top = 0; } else { // nothing here } fm.descent = 0; fm.bottom = 0; } }
float addStyleRun(TextPaint paint, MetricAffectingSpan[] spans, int len, FontMetricsInt fm) { int i; float wid; TextPaint workPaint = this.mWorkPaint; workPaint.set(paint); workPaint.baselineShift = 0; ReplacementSpan replacement = null; for (MetricAffectingSpan span : spans) { if (span instanceof ReplacementSpan) { replacement = (ReplacementSpan) span; } else { span.updateMeasureState(workPaint); } } if (replacement == null) { wid = addStyleRun(workPaint, len, fm); } else { wid = (float) replacement.getSize( workPaint, this.mText, this.mTextStart + this.mPos, (this.mTextStart + this.mPos) + len, fm); float[] w = this.mWidths; w[this.mPos] = wid; int e = this.mPos + len; for (i = this.mPos + 1; i < e; i++) { w[i] = 0.0f; } this.mPos += len; } if (fm != null) { if (workPaint.baselineShift < 0) { fm.ascent += workPaint.baselineShift; fm.top += workPaint.baselineShift; } else { fm.descent += workPaint.baselineShift; fm.bottom += workPaint.baselineShift; } } return wid; }