Example usage for android.graphics Typeface BOLD

List of usage examples for android.graphics Typeface BOLD

Introduction

In this page you can find the example usage for android.graphics Typeface BOLD.

Prototype

int BOLD

To view the source code for android.graphics Typeface BOLD.

Click Source Link

Usage

From source file:Main.java

public static void TextView_setFontBold(TextView v) {
    v.setTypeface(null, Typeface.BOLD);
}

From source file:Main.java

public static SpannableString bold(SpannableString sequence) {
    sequence.setSpan(new StyleSpan(Typeface.BOLD), 0, sequence.length(), 0);
    return sequence;
}

From source file:Main.java

public static CharSequence setTextStyleBold(CharSequence text) {
    final StyleSpan style = new StyleSpan(Typeface.BOLD);
    final SpannableString str = new SpannableString(text);
    str.setSpan(style, 0, text.length(), 0);

    return str;/*from   w  w w. ja v  a 2 s  . c om*/
}

From source file:Main.java

public static SpannableStringBuilder applyBoldStyle(String text) {
    SpannableStringBuilder ss = new SpannableStringBuilder(text);
    ss.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ss;//from   w ww  . j av a  2 s . c  om
}

From source file:Main.java

public static CharSequence bold(CharSequence sequence) {
    SpannableString spannable = new SpannableString(sequence);
    spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannable;
}

From source file:Main.java

public static int toTypefaceStyle(String fontWeight) {
    int style = Typeface.NORMAL;
    if (fontWeight != null) {
        if (fontWeight.equals("bold")) {
            style = Typeface.BOLD;
        }//  ww w. jav a2s  .c o m
    }
    return style;
}

From source file:Main.java

/**
 * Returns a CharSequence that applies boldface to the concatenation
 * of the specified CharSequence objects.
 *///from  ww  w .j a  v a2  s. com
public static CharSequence bold(CharSequence... content) {
    return apply(content, new StyleSpan(Typeface.BOLD));
}

From source file:Main.java

public static int toTypefaceStyle(String fontWeight, String fontStyle) {
    int style = Typeface.NORMAL;

    if (fontWeight != null) {
        if (fontWeight.equals("bold")) {
            if (fontStyle != null && fontStyle.equals("italic")) {
                style = Typeface.BOLD_ITALIC;
            } else {
                style = Typeface.BOLD;
            }//  ww w .  java2s . c  om
        } else if (fontStyle != null && fontStyle.equals("italic")) {
            style = Typeface.ITALIC;
        }
    } else if (fontStyle != null && fontStyle.equals("italic")) {
        style = Typeface.ITALIC;
    }
    return style;
}

From source file:Main.java

public static Bitmap drawTextToBitmap(Context context, int resId, String text) {

    Resources resources = context.getResources();
    float scale = resources.getDisplayMetrics().density;
    Bitmap bitmap = BitmapFactory.decodeResource(resources, resId);

    Bitmap.Config bitmapConfig = bitmap.getConfig();
    if (bitmapConfig == null)
        bitmapConfig = Bitmap.Config.ARGB_8888;
    bitmap = bitmap.copy(bitmapConfig, true);

    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(context.getResources().getColor(android.R.color.white));
    paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
    paint.setTextSize((int) (12 * scale));

    Rect bounds = new Rect();
    paint.getTextBounds(text, 0, text.length(), bounds);
    int x = (bitmap.getWidth() - bounds.width()) / 4;
    int y = (bitmap.getHeight() + bounds.height()) / 5;

    canvas.drawText(text, x * scale, y * scale, paint);

    return bitmap;
}

From source file:Main.java

public static CharSequence getBoldedString(String value) {
    SpannableString spanned = new SpannableString(value);
    spanned.setSpan(new StyleSpan(Typeface.BOLD), 0, spanned.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    return spanned;
}