android.text.TextPaint#reset ( )源码实例Demo

下面列出了android.text.TextPaint#reset ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: react-native-text-size   文件: RNTextSizeModule.java
/**
 * https://stackoverflow.com/questions/27631736
 * /meaning-of-top-ascent-baseline-descent-bottom-and-leading-in-androids-font
 */
@SuppressWarnings("unused")
@ReactMethod
public void fontFromSpecs(@Nullable final ReadableMap specs, final Promise promise) {
    final RNTextSizeConf conf = getConf(specs, promise);
    if (conf == null) {
        return;
    }
    final Typeface typeface = RNTextSizeConf.getFont(mReactContext, conf.fontFamily, conf.fontStyle);
    final TextPaint textPaint = sTextPaintInstance;
    final int fontSize = (int) Math.ceil(conf.scale(conf.fontSize));

    textPaint.reset();
    textPaint.setTypeface(typeface);
    textPaint.setTextSize(fontSize);

    promise.resolve(fontInfoFromTypeface(textPaint, typeface, conf));
}
 
源代码2 项目: letv   文件: AndroidDisplayer.java
private synchronized TextPaint getPaint(BaseDanmaku danmaku, boolean quick) {
    TextPaint paint;
    if (quick) {
        paint = this.PAINT_DUPLICATE;
        paint.set(this.PAINT);
    } else {
        paint = this.PAINT;
    }
    paint.reset();
    paint.setTextSize(danmaku.textSize);
    applyTextScaleConfig(danmaku, paint);
    if (!this.HAS_SHADOW || this.SHADOW_RADIUS <= 0.0f || danmaku.textShadowColor == 0) {
        paint.clearShadowLayer();
    } else {
        paint.setShadowLayer(this.SHADOW_RADIUS, 0.0f, 0.0f, danmaku.textShadowColor);
    }
    paint.setAntiAlias(this.ANTI_ALIAS);
    return paint;
}