Code example for TextPaint

Methods: setTypefaceellipsize

    public static StringTexture newInstance( 
            String text, float textSize, int color,
            float lengthLimit, boolean isBold) {
        TextPaint paint = getDefaultPaint(textSize, color);
        if (isBold) {
        text = TextUtils.ellipsize(
                text, paint, lengthLimit, TextUtils.TruncateAt.END).toString();
        return newInstance(text, paint);
    private static StringTexture newInstance(String text, TextPaint paint) {
        FontMetricsInt metrics = paint.getFontMetricsInt();
        int width = (int) Math.ceil(paint.measureText(text));
        int height = metrics.bottom -;
        // The texture size needs to be at least 1x1. 
        if (width <= 0) width = 1;
        if (height <= 0) height = 1;
        return new StringTexture(text, paint, metrics, width, height);
Contextual code suggestions in your IDE  Get Codota for Java