Example usage for android.graphics Paint getFontMetricsInt

List of usage examples for android.graphics Paint getFontMetricsInt

Introduction

In this page you can find the example usage for android.graphics Paint getFontMetricsInt.

Prototype

public int getFontMetricsInt(FontMetricsInt fmi) 

Source Link

Document

Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc.

Usage

From source file:android.support.text.emoji.EmojiSpan.java

@Override
public int getSize(@NonNull final Paint paint, final CharSequence text, final int start, final int end,
        final Paint.FontMetricsInt fm) {
    paint.getFontMetricsInt(mTmpFontMetrics);
    final int fontHeight = Math.abs(mTmpFontMetrics.descent - mTmpFontMetrics.ascent);

    mRatio = fontHeight * 1.0f / mMetadata.getHeight();
    mHeight = (short) (mMetadata.getHeight() * mRatio);
    mWidth = (short) (mMetadata.getWidth() * mRatio);

    if (fm != null) {
        fm.ascent = mTmpFontMetrics.ascent;
        fm.descent = mTmpFontMetrics.descent;
        fm.top = mTmpFontMetrics.top;/*  ww w.j a v  a  2 s  . com*/
        fm.bottom = mTmpFontMetrics.bottom;
    }

    return mWidth;
}