Search in sources :

Example 71 with Typeface

use of android.graphics.Typeface in project XobotOS by xamarin.

the class TextView method setTypefaceByIndex.

private void setTypefaceByIndex(int typefaceIndex, int styleIndex) {
    Typeface tf = null;
    switch(typefaceIndex) {
        case SANS:
            tf = Typeface.SANS_SERIF;
            break;
        case SERIF:
            tf = Typeface.SERIF;
            break;
        case MONOSPACE:
            tf = Typeface.MONOSPACE;
            break;
    }
    setTypeface(tf, styleIndex);
}
Also used : Typeface(android.graphics.Typeface)

Example 72 with Typeface

use of android.graphics.Typeface in project Weather by Sparker0i.

the class LargeWidgetProvider method createWeatherIcon.

public static Bitmap createWeatherIcon(Context context, String text) {
    Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    Typeface weatherFont = Typeface.createFromAsset(context.getAssets(), "fonts/weather.ttf");
    int textColor = ContextCompat.getColor(context, R.color.textColor);
    paint.setAntiAlias(true);
    paint.setSubpixelText(true);
    paint.setTypeface(weatherFont);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(textColor);
    paint.setTextSize(180);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(text, 128, 200, paint);
    return bitmap;
}
Also used : Bitmap(android.graphics.Bitmap) Typeface(android.graphics.Typeface) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 73 with Typeface

use of android.graphics.Typeface in project Weather by Sparker0i.

the class SmallWidgetProvider method createWeatherIcon.

public static Bitmap createWeatherIcon(Context context, String text) {
    Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    Typeface weatherFont = Typeface.createFromAsset(context.getAssets(), "fonts/weather.ttf");
    int textColor = ContextCompat.getColor(context, R.color.textColor);
    paint.setAntiAlias(true);
    paint.setSubpixelText(true);
    paint.setTypeface(weatherFont);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(textColor);
    paint.setTextSize(180);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(text, 128, 200, paint);
    return bitmap;
}
Also used : Bitmap(android.graphics.Bitmap) Typeface(android.graphics.Typeface) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 74 with Typeface

use of android.graphics.Typeface in project letterpress by Pixplicity.

the class FontTextView method setCustomTypeface.

public void setCustomTypeface(String font) {
    final Typeface tf = FontUtil.getTypeface(getContext(), font);
    setCustomTypeface(tf);
}
Also used : Typeface(android.graphics.Typeface)

Example 75 with Typeface

use of android.graphics.Typeface in project letterpress by Pixplicity.

the class FontSpan method apply.

private void apply(final Paint paint) {
    final Typeface oldTypeface = paint.getTypeface();
    final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0;
    final int fakeStyle = oldStyle & ~typeface.getStyle();
    if ((fakeStyle & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }
    if ((fakeStyle & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }
    paint.setTypeface(typeface);
}
Also used : Typeface(android.graphics.Typeface) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Aggregations

Typeface (android.graphics.Typeface)266 Paint (android.graphics.Paint)57 TextPaint (android.text.TextPaint)40 TypedArray (android.content.res.TypedArray)34 TextView (android.widget.TextView)21 View (android.view.View)20 Canvas (android.graphics.Canvas)15 Bitmap (android.graphics.Bitmap)13 Context (android.content.Context)11 Resources (android.content.res.Resources)10 Test (org.junit.Test)8 ColorStateList (android.content.res.ColorStateList)7 Legend (com.github.mikephil.charting.components.Legend)7 File (java.io.File)7 Intent (android.content.Intent)6 Attributes (com.cengalabs.flatui.Attributes)6 XAxis (com.github.mikephil.charting.components.XAxis)6 YAxis (com.github.mikephil.charting.components.YAxis)6 ContentResolver (android.content.ContentResolver)5 Drawable (android.graphics.drawable.Drawable)5