Example usage for android.graphics Typeface DEFAULT

List of usage examples for android.graphics Typeface DEFAULT

Introduction

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

Prototype

Typeface DEFAULT

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

Click Source Link

Document

The default NORMAL typeface object

Usage

From source file:Main.java

public static Typeface getTypface(@Nullable String font_name, Context mContext) {
    if (font_name == null)
        return Typeface.DEFAULT;
    return Typeface.createFromAsset(mContext.getAssets(), "fonts/" + font_name);
}

From source file:Main.java

public static Typeface GetTypeface() {
    if ("en".equals(Locale.getDefault().getLanguage()))
        return typefaceLatoLight;
    if ("zh".equals(Locale.getDefault().getLanguage()))
        return Typeface.DEFAULT;
    return typefaceLatoLight;
}

From source file:Main.java

public static Typeface getTypeface(Context c, String name) {
    synchronized (typefaces) {
        if (!typefaces.containsKey(name)) {
            try {
                InputStream inputStream = c.getAssets().open(name);
                File file = createFileFromInputStream(inputStream, name);
                if (file == null) {
                    return Typeface.DEFAULT;
                }/*  ww w.j a  v a2s .co m*/
                Typeface t = Typeface.createFromFile(file);
                typefaces.put(name, t);
            } catch (Exception e) {
                e.printStackTrace();
                return Typeface.DEFAULT;
            }
        }
        return typefaces.get(name);
    }
}

From source file:Main.java

public static Bitmap getTextImage(String text, float size, int width, int height) {
    final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    final Paint paint = new Paint();
    final Canvas canvas = new Canvas(bmp);

    canvas.drawColor(Color.WHITE);

    paint.setColor(Color.BLACK);/*  w w w  . ja  v  a  2s  .c o  m*/
    paint.setStyle(Style.FILL);
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(size);
    paint.setTypeface(Typeface.DEFAULT);
    canvas.drawText(text, width / 2, height / 2, paint);

    return bmp;
}

From source file:com.bobomee.android.common.util.EditUtil.java

/**
 * ??EditTextView//from   w  ww  .  j a v a2  s . c o m
 */
public static void passEditText(EditText password) {
    password.setTypeface(Typeface.DEFAULT);
    password.setTransformationMethod(new PasswordTransformationMethod());
}

From source file:Main.java

private static Paint getTextPaint(float size) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setShadowLayer(1, 1, 1, 0xFF000000);
    paint.setColor(0xFFFFFFFF);/* w  ww. j a va  2 s . co m*/
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(size);
    paint.setTypeface(Typeface.DEFAULT);
    return paint;

}

From source file:Main.java

private static Typeface getTextTypeface(@Nullable final CharSequence text) {
    return hasStyleSpan(text, BOLD_SPAN) ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT;
}

From source file:io.github.hidroh.materialistic.widget.PeekabooTouchHelperCallback.java

PeekabooTouchHelperCallback(Context context) {
    super(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
    mDefaultTextColor = ContextCompat.getColor(context,
            AppUtils.getThemedResId(context, android.R.attr.textColorPrimary));
    mPaint.setTextSize(context.getResources().getDimensionPixelSize(R.dimen.text_size_small));
    mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
    mPadding = context.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
}

From source file:com.module.candychat.net.view.custom.SimpleAssetFontLoader.java

@Override
public Typeface getTypeFace(String typefaceName) {
    Typeface typeface = sTypefaceCache.get(typefaceName);

    if (typeface == null) {
        String fontFile = mFolderForPath + typefaceName + "." + mExtension;

        try {//from w  ww.j  ava 2s .  c o m
            typeface = Typeface.createFromAsset(mAssetManager, fontFile);
            sTypefaceCache.put(typefaceName, typeface);
        } catch (RuntimeException e) {
            return Typeface.DEFAULT;
        }
    }
    return typeface;
}

From source file:com.github.dfa.diaspora_android.ui.BadgeDrawable.java

public BadgeDrawable(Context context) {
    float textSize = context.getResources().getDimension(R.dimen.textsize_badge_count);

    AppSettings settings = new AppSettings(context);
    badgeBackground = new Paint();
    badgeBackground.setColor(settings.getAccentColor());
    badgeBackground.setAntiAlias(true);//from ww  w.j av a 2s. co  m
    badgeBackground.setStyle(Paint.Style.FILL);
    badgeStroke = new Paint();
    badgeStroke.setColor(ContextCompat.getColor(context.getApplicationContext(), R.color.colorPrimaryDark));
    badgeStroke.setAntiAlias(true);
    badgeStroke.setStyle(Paint.Style.FILL);

    badgeText = new Paint();
    badgeText.setColor(Color.WHITE);
    badgeText.setTypeface(Typeface.DEFAULT);
    badgeText.setTextSize(textSize);
    badgeText.setAntiAlias(true);
    badgeText.setTextAlign(Paint.Align.CENTER);
}