android.graphics.Paint.FontMetricsInt Java Examples

The following examples show how to use android.graphics.Paint.FontMetricsInt. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmojiTextView.java    From Silence with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  final int size = MeasureSpec.getSize(widthMeasureSpec);
  final int mode = MeasureSpec.getMode(widthMeasureSpec);
  if (!useSystemEmoji()                                            &&
      getEllipsize() == TruncateAt.END                             &&
      !TextUtils.isEmpty(source)                                   &&
      (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) &&
      getPaint().breakText(source, 0, source.length()-1, true, size, null) != source.length())
  {
    needsEllipsizing = true;
    FontMetricsInt font = getPaint().getFontMetricsInt();
    super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(Math.abs(font.top - font.bottom), MeasureSpec.EXACTLY));
  } else {
    needsEllipsizing = false;
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}
 
Example #2
Source File: Cocos2dxBitmap.java    From Earlybird with Apache License 2.0 6 votes vote down vote up
private static int computeY(final FontMetricsInt fontMetricsInt,
		final int constrainHeight, final int totalHeight,
		final int verticalAlignment) {
	int y = -fontMetricsInt.top;

	if (constrainHeight > totalHeight) {
		switch (verticalAlignment) {
		case VERTICALALIGN_TOP:
			y = -fontMetricsInt.top;
			break;
		case VERTICALALIGN_CENTER:
			y = -fontMetricsInt.top + (constrainHeight - totalHeight)
					/ 2;
			break;
		case VERTICALALIGN_BOTTOM:
			y = -fontMetricsInt.top + (constrainHeight - totalHeight);
			break;
		default:
			break;
		}
	}

	return y;
}
 
Example #3
Source File: Cocos2dxBitmap.java    From Earlybird with Apache License 2.0 6 votes vote down vote up
private static TextProperty computeTextProperty(final String string,
		final int width, final int height, final Paint paint) {
	final FontMetricsInt fm = paint.getFontMetricsInt();
	final int h = (int) Math.ceil(fm.bottom - fm.top);
	int maxContentWidth = 0;

	final String[] lines = Cocos2dxBitmap.splitString(string, width,
			height, paint);

	if (width != 0) {
		maxContentWidth = width;
	} else {
		/* Compute the max width. */
		int temp = 0;
		for (final String line : lines) {
			temp = (int) FloatMath.ceil(paint.measureText(line, 0,
					line.length()));
			if (temp > maxContentWidth) {
				maxContentWidth = temp;
			}
		}
	}

	return new TextProperty(maxContentWidth, h, lines);
}
 
Example #4
Source File: Cocos2dxBitmap.java    From Example-of-Cocos2DX with MIT License 6 votes vote down vote up
private static int computeY(final FontMetricsInt fontMetricsInt,
		final int constrainHeight, final int totalHeight,
		final int verticalAlignment) {
	int y = -fontMetricsInt.top;

	if (constrainHeight > totalHeight) {
		switch (verticalAlignment) {
		case VERTICALALIGN_TOP:
			y = -fontMetricsInt.top;
			break;
		case VERTICALALIGN_CENTER:
			y = -fontMetricsInt.top + (constrainHeight - totalHeight)
					/ 2;
			break;
		case VERTICALALIGN_BOTTOM:
			y = -fontMetricsInt.top + (constrainHeight - totalHeight);
			break;
		default:
			break;
		}
	}

	return y;
}
 
Example #5
Source File: AnimatedImageSpan.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
/**
 * 代码跟父类代码相似,就是getCachedDrawable()替换成getDrawable(),因为前者里面的图片是WeakReference,
 * 容易被gc回收,所以这里要避免这个问题
 */
@Override
public int getSize(Paint paint, CharSequence text, int start, int end,
                   FontMetricsInt fm) {
    Drawable d = getDrawable();

    if (lineHeight > 0) {
        return (int) (d.getIntrinsicWidth() * scale);
    } else {
        Rect rect = d.getBounds();

        if (fm != null) {
            fm.ascent = -rect.bottom;
            fm.descent = 0;

            fm.top = fm.ascent;
            fm.bottom = 0;
        }
        return rect.right;

    }
}
 
Example #6
Source File: Cocos2dxBitmap.java    From Example-of-Cocos2DX with MIT License 6 votes vote down vote up
private static TextProperty computeTextProperty(final String string,
		final int width, final int height, final Paint paint) {
	final FontMetricsInt fm = paint.getFontMetricsInt();
	final int h = (int) Math.ceil(fm.bottom - fm.top);
	int maxContentWidth = 0;

	final String[] lines = Cocos2dxBitmap.splitString(string, width,
			height, paint);

	if (width != 0) {
		maxContentWidth = width;
	} else {
		/* Compute the max width. */
		int temp = 0;
		for (final String line : lines) {
			temp = (int) FloatMath.ceil(paint.measureText(line, 0,
					line.length()));
			if (temp > maxContentWidth) {
				maxContentWidth = temp;
			}
		}
	}

	return new TextProperty(maxContentWidth, h, lines);
}
 
Example #7
Source File: Cocos2dxBitmap.java    From Example-of-Cocos2DX with MIT License 6 votes vote down vote up
private static int computeY(final FontMetricsInt fontMetricsInt,
		final int constrainHeight, final int totalHeight,
		final int verticalAlignment) {
	int y = -fontMetricsInt.top;

	if (constrainHeight > totalHeight) {
		switch (verticalAlignment) {
		case VERTICALALIGN_TOP:
			y = -fontMetricsInt.top;
			break;
		case VERTICALALIGN_CENTER:
			y = -fontMetricsInt.top + (constrainHeight - totalHeight)
					/ 2;
			break;
		case VERTICALALIGN_BOTTOM:
			y = -fontMetricsInt.top + (constrainHeight - totalHeight);
			break;
		default:
			break;
		}
	}

	return y;
}
 
Example #8
Source File: PickerView.java    From YiZhi with Apache License 2.0 6 votes vote down vote up
private void drawData(Canvas canvas) {
    // 先绘制选中的text再往上往下绘制其余的text
    float scale = parabola(mViewHeight / 4.0f, mMoveLen);
    float size = (mMaxTextSize - mMinTextSize) * scale + mMinTextSize;
    mPaint.setTextSize(size);
    mPaint.setAlpha((int) ((mMaxTextAlpha - mMinTextAlpha) * scale + mMinTextAlpha));
    // text居中绘制,注意baseline的计算才能达到居中,y值是text中心坐标
    float x = (float) (mViewWidth / 2.0);
    float y = (float) (mViewHeight / 2.0 + mMoveLen);
    FontMetricsInt fmi = mPaint.getFontMetricsInt();
    float baseline = (float) (y - (fmi.bottom / 2.0 + fmi.top / 2.0));
    if (mDataList.size() > 0) {
        canvas.drawText(mDataList.get(mCurrentSelected), x, baseline,
                mPaint);
    }
    // 绘制上方data
    for (int i = 1; (mCurrentSelected - i) >= 0; i++) {
        drawOtherText(canvas, i, -1);
    }
    // 绘制下方data
    for (int i = 1; (mCurrentSelected + i) < mDataList.size(); i++) {
        drawOtherText(canvas, i, 1);
    }
}
 
Example #9
Source File: Cocos2dxBitmap.java    From Example-of-Cocos2DX with MIT License 6 votes vote down vote up
private static TextProperty computeTextProperty(final String string,
		final int width, final int height, final Paint paint) {
	final FontMetricsInt fm = paint.getFontMetricsInt();
	final int h = (int) Math.ceil(fm.bottom - fm.top);
	int maxContentWidth = 0;

	final String[] lines = Cocos2dxBitmap.splitString(string, width,
			height, paint);

	if (width != 0) {
		maxContentWidth = width;
	} else {
		/* Compute the max width. */
		int temp = 0;
		for (final String line : lines) {
			temp = (int) FloatMath.ceil(paint.measureText(line, 0,
					line.length()));
			if (temp > maxContentWidth) {
				maxContentWidth = temp;
			}
		}
	}

	return new TextProperty(maxContentWidth, h, lines);
}
 
Example #10
Source File: ErrorFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.lb_error_fragment, container, false);

    mErrorFrame = root.findViewById(R.id.error_frame);
    updateBackground();

    mImageView = (ImageView) root.findViewById(R.id.image);
    updateImageDrawable();

    mTextView = (TextView) root.findViewById(R.id.message);
    updateMessage();

    mButton = (Button) root.findViewById(R.id.button);
    updateButton();

    mTitleView = (TitleView) root.findViewById(R.id.browse_title_group);
    updateTitle();

    FontMetricsInt metrics = getFontMetricsInt(mTextView);
    int underImageBaselineMargin = container.getResources().getDimensionPixelSize(
            R.dimen.lb_error_under_image_baseline_margin);
    setTopMargin(mTextView, underImageBaselineMargin + metrics.ascent);

    int underMessageBaselineMargin = container.getResources().getDimensionPixelSize(
            R.dimen.lb_error_under_message_baseline_margin);
    setTopMargin(mButton, underMessageBaselineMargin - metrics.descent);

    return root;
}
 
Example #11
Source File: EmojiSpan.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
@Override public int getSize(Paint paint, CharSequence text, int start, int end,
                             FontMetricsInt fm)
{
  if (fm != null && this.fm != null) {
    fm.ascent  = this.fm.ascent;
    fm.descent = this.fm.descent;
    fm.top     = this.fm.top;
    fm.bottom  = this.fm.bottom;
    return size;
  } else {
    return super.getSize(paint, text, start, end, fm);
  }
}
 
Example #12
Source File: TextLineImpl15.java    From FastTextView with Apache License 2.0 5 votes vote down vote up
/**
 * @param wp
 */
private static void expandMetricsFromPaint(FontMetricsInt fmi, TextPaint wp) {
  final int previousTop = fmi.top;
  final int previousAscent = fmi.ascent;
  final int previousDescent = fmi.descent;
  final int previousBottom = fmi.bottom;
  final int previousLeading = fmi.leading;

  wp.getFontMetricsInt(fmi);

  updateMetrics(fmi, previousTop, previousAscent, previousDescent, previousBottom,
      previousLeading);
}
 
Example #13
Source File: TextLineImpl15.java    From FastTextView with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #14
Source File: TextLineImpl23.java    From FastTextView with Apache License 2.0 5 votes vote down vote up
/**
 * @param wp
 */
private static void expandMetricsFromPaint(FontMetricsInt fmi, TextPaint wp) {
  final int previousTop = fmi.top;
  final int previousAscent = fmi.ascent;
  final int previousDescent = fmi.descent;
  final int previousBottom = fmi.bottom;
  final int previousLeading = fmi.leading;

  wp.getFontMetricsInt(fmi);

  updateMetrics(fmi, previousTop, previousAscent, previousDescent, previousBottom,
      previousLeading);
}
 
Example #15
Source File: TextLineImpl23.java    From FastTextView with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #16
Source File: WeekDatePicker.java    From WeekDatePicker with MIT License 5 votes vote down vote up
private static BoringLayout.Metrics toBoringFontMetrics(FontMetricsInt metrics,
        @Nullable BoringLayout.Metrics fontMetrics) {

    if (fontMetrics == null) {
        fontMetrics = new BoringLayout.Metrics();
    }

    fontMetrics.ascent = metrics.ascent;
    fontMetrics.bottom = metrics.bottom;
    fontMetrics.descent = metrics.descent;
    fontMetrics.leading = metrics.leading;
    fontMetrics.top = metrics.top;
    return fontMetrics;
}
 
Example #17
Source File: EmojiSpan.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
  if (fm != null && this.fm != null) {
    fm.ascent  = this.fm.ascent;
    fm.descent = this.fm.descent;
    fm.top     = this.fm.top;
    fm.bottom  = this.fm.bottom;
    fm.leading = this.fm.leading;
    return size;
  } else {
    return super.getSize(paint, text, start, end, fm);
  }
}
 
Example #18
Source File: LoadPercentImageView.java    From QiQuYing with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
	if(!isLoadImg) {  //如果不加载图片,则只显示背景
		super.onDraw(canvas);
		return;
	}
	if(isComplete) {
		super.onDraw(canvas);
		return;
	}
	mXCenter = getWidth() / 2;
	mYCenter = getHeight() / 2;
	canvas.drawCircle(mXCenter, mYCenter, mRingRadius, mCirclePaint);
	
	if (mProgress >= 0) {
		//设置椭圆上下左右的坐标
		oval.left = mXCenter - mRingRadius;  
		oval.top = mYCenter - mRingRadius;
		oval.right = mXCenter + mRingRadius;
		oval.bottom = mYCenter + mRingRadius;
		canvas.drawArc(oval, -90, ((float)mProgress / mTotalProgress) * 360, false, mRingPaint); //
		
		String percentTxt = mProgress + "%";
		//计算文字垂直居中的baseline
		FontMetricsInt fontMetrics = mTxtPaint.getFontMetricsInt();
		float baseline = oval.top + (oval.bottom - oval.top - fontMetrics.bottom + fontMetrics.top) / 2 - fontMetrics.top;
		canvas.drawText(percentTxt, mXCenter, baseline, mTxtPaint);
	}
}
 
Example #19
Source File: SlashSpan.java    From android-card-form with MIT License 5 votes vote down vote up
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
    float padding = paint.measureText(" ", 0, 1) * 2;
    float slash = paint.measureText("/", 0, 1);
    float textSize = paint.measureText(text, start, end);
    return (int) (padding + slash + textSize);
}
 
Example #20
Source File: LabelSpan.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
private void setupFontMetrics(CharSequence text, int start, int end, FontMetricsInt fm, Paint p) {
    txtPaint.set(p);
    final CharacterStyle[] otherSpans = ((Spanned) text).getSpans(start, end, CharacterStyle.class);
    for (CharacterStyle otherSpan : otherSpans) {
        otherSpan.updateDrawState(txtPaint);
    }
    txtPaint.setTextSize(p.getTextSize());
    if (fm != null) {
        txtPaint.getFontMetricsInt(fm);
    }
}
 
Example #21
Source File: LabelSpan.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
@Override public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
    setupFontMetrics(text, start, end, fm, paint);
    if (fm != null) {
        final int padding = dims.getPadding();
        final int margin = dims.getMarginTop();
        fm.ascent = Math.min(fm.top, fm.ascent - padding) - margin;
        fm.descent = Math.max(fm.bottom, padding);
        fm.top = fm.ascent;
        fm.bottom = fm.descent;
    }
    return measureWidth(txtPaint, text, start, end, dims.isRtl());
}
 
Example #22
Source File: VideoShotEditActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private boolean saveFileAddedVoice(String path, String voice, String savePath) {
    LogInfo.log("fornia", "voice:" + voice);
    if (!new File(path).exists()) {
        return false;
    }
    Options options = new Options();
    options.inJustDecodeBounds = false;
    Bitmap bitmap0 = BitmapFactory.decodeFile(path, options);
    int width = options.outWidth;
    int height = options.outHeight;
    Bitmap bitmapPic = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapPic);
    canvas.drawBitmap(bitmap0, null, new Rect(0, 0, width, height), null);
    Rect targetBgRect = new Rect(0, height - getTextBgHeight(), width, height);
    if (!isOrigPicMode) {
        Paint voiceBgPaint = new Paint();
        voiceBgPaint.setColor(getResources().getColor(2131493164));
        voiceBgPaint.setStyle(Style.FILL);
        voiceBgPaint.setFlags(2);
        canvas.drawRect(targetBgRect, voiceBgPaint);
        voiceBgPaint.setColor(-1);
        voiceBgPaint.setTextSize((float) getTextSize());
        voiceBgPaint.setTextAlign(Align.CENTER);
        FontMetricsInt fontMetrics = voiceBgPaint.getFontMetricsInt();
        String str = voice;
        canvas.drawText(str, (float) targetBgRect.centerX(), (float) ((targetBgRect.top + ((((targetBgRect.bottom - targetBgRect.top) - fontMetrics.bottom) + fontMetrics.top) / 2)) - fontMetrics.top), voiceBgPaint);
    }
    return FileUtils.saveBitmapByUser(this.mContext, bitmapPic);
}
 
Example #23
Source File: ErrorSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.lb_error_fragment, container, false);

    mErrorFrame = root.findViewById(R.id.error_frame);
    updateBackground();

    mImageView = (ImageView) root.findViewById(R.id.image);
    updateImageDrawable();

    mTextView = (TextView) root.findViewById(R.id.message);
    updateMessage();

    mButton = (Button) root.findViewById(R.id.button);
    updateButton();

    mTitleView = (TitleView) root.findViewById(R.id.browse_title_group);
    updateTitle();

    FontMetricsInt metrics = getFontMetricsInt(mTextView);
    int underImageBaselineMargin = container.getResources().getDimensionPixelSize(
            R.dimen.lb_error_under_image_baseline_margin);
    setTopMargin(mTextView, underImageBaselineMargin + metrics.ascent);

    int underMessageBaselineMargin = container.getResources().getDimensionPixelSize(
            R.dimen.lb_error_under_message_baseline_margin);
    setTopMargin(mButton, underMessageBaselineMargin - metrics.descent);

    return root;
}
 
Example #24
Source File: VideoShotEditActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private String getFileAddedWatermark(String path, String text, String voice) {
    if (!new File(path).exists()) {
        return null;
    }
    Options options = new Options();
    options.inJustDecodeBounds = false;
    Bitmap bitmap0 = BitmapFactory.decodeFile(path, options);
    int width = options.outWidth;
    int height = options.outHeight;
    Bitmap bitmapPic = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapPic);
    canvas.drawBitmap(bitmap0, null, new Rect(0, 0, width, height), null);
    Paint textPaint = new Paint();
    textPaint.setColor(-1);
    textPaint.setTextSize((float) getTextSize());
    textPaint.setFlags(2);
    canvas.drawText(text, 0, text.length(), 30.0f, 50.0f, textPaint);
    Rect rect = new Rect(0, height - getTextBgHeight(), width, height);
    if (!isOrigPicMode) {
        Paint voiceBgPaint = new Paint();
        voiceBgPaint.setColor(getResources().getColor(2131493164));
        voiceBgPaint.setStyle(Style.FILL);
        voiceBgPaint.setFlags(2);
        canvas.drawRect(rect, voiceBgPaint);
        voiceBgPaint.setColor(-1);
        voiceBgPaint.setTextSize((float) getTextSize());
        voiceBgPaint.setTextAlign(Align.CENTER);
        FontMetricsInt fontMetrics = voiceBgPaint.getFontMetricsInt();
        int baseline = (rect.top + ((((rect.bottom - rect.top) - fontMetrics.bottom) + fontMetrics.top) / 2)) - fontMetrics.top;
        canvas.drawText(voice, (float) rect.centerX(), (float) baseline, voiceBgPaint);
    }
    return saveBitmap(bitmapPic);
}
 
Example #25
Source File: PickerView.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
/**
 * @param canvas
 * @param position 距离mCurrentSelected的差值
 * @param type     1表示向下绘制,-1表示向上绘制
 */
private void drawOtherText(Canvas canvas, int position, int type) {
    float d = (float) (MARGIN_ALPHA * mMinTextSize * position + type
            * mMoveLen);
    float scale = parabola(mViewHeight / 4.0f, d);
    float size = (mMaxTextSize - mMinTextSize) * scale + mMinTextSize;
    mPaint.setTextSize(size);
    mPaint.setAlpha((int) ((mMaxTextAlpha - mMinTextAlpha) * scale + mMinTextAlpha));
    float y = (float) (mViewHeight / 2.0 + type * d);
    FontMetricsInt fmi = mPaint.getFontMetricsInt();
    float baseline = (float) (y - (fmi.bottom / 2.0 + fmi.top / 2.0));
    canvas.drawText(mDataList.get(mCurrentSelected + type * position),
            (float) (mViewWidth / 2.0), baseline, mPaint);
}
 
Example #26
Source File: TintedDrawableSpan.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
    fm = fm == null ? paint.getFontMetricsInt() : fm;
    int iconSize = fm.bottom - fm.top;
    mDrawable.setBounds(0, 0, iconSize, iconSize);
    return super.getSize(paint, text, start, end, fm);
}
 
Example #27
Source File: EmojiSpan.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
    if (fm != null && this.fm != null) {
        fm.ascent = this.fm.ascent;
        fm.descent = this.fm.descent;
        fm.top = this.fm.top;
        fm.bottom = this.fm.bottom;
        fm.leading = this.fm.leading;
        return size;
    } else {
        return super.getSize(paint, text, start, end, fm);
    }
}
 
Example #28
Source File: EmojiSpan.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
  if (fm != null && this.fm != null) {
    fm.ascent  = this.fm.ascent;
    fm.descent = this.fm.descent;
    fm.top     = this.fm.top;
    fm.bottom  = this.fm.bottom;
    fm.leading = this.fm.leading;
    return size;
  } else {
    return super.getSize(paint, text, start, end, fm);
  }
}
 
Example #29
Source File: TextLine.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #30
Source File: TextLine.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * @param wp
 */
private static void expandMetricsFromPaint(FontMetricsInt fmi, TextPaint wp) {
    final int previousTop     = fmi.top;
    final int previousAscent  = fmi.ascent;
    final int previousDescent = fmi.descent;
    final int previousBottom  = fmi.bottom;
    final int previousLeading = fmi.leading;

    wp.getFontMetricsInt(fmi);

    updateMetrics(fmi, previousTop, previousAscent, previousDescent, previousBottom,
            previousLeading);
}