Search in sources :

Example 36 with Typeface

use of android.graphics.Typeface in project Calligraphy by chrisjenx.

the class CalligraphyTypefaceSpan 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)

Example 37 with Typeface

use of android.graphics.Typeface in project Calligraphy by chrisjenx.

the class CalligraphyUtils method applyFontToTextView.

static boolean applyFontToTextView(final Context context, final TextView textView, final String filePath, boolean deferred) {
    if (textView == null || context == null)
        return false;
    final AssetManager assetManager = context.getAssets();
    final Typeface typeface = TypefaceUtils.load(assetManager, filePath);
    return applyFontToTextView(textView, typeface, deferred);
}
Also used : AssetManager(android.content.res.AssetManager) Typeface(android.graphics.Typeface)

Example 38 with Typeface

use of android.graphics.Typeface in project Print by johnkil.

the class PrintConfig method initDefault.

/**
     * Define the default iconic font.
     *
     * @param assets          The application's asset manager.
     * @param defaultFontPath The file name of the font in the assets directory,
     *                        e.g. "fonts/iconic-font.ttf".
     * @see #initDefault(Typeface)
     */
public static void initDefault(AssetManager assets, String defaultFontPath) {
    Typeface defaultFont = TypefaceManager.load(assets, defaultFontPath);
    initDefault(defaultFont);
}
Also used : Typeface(android.graphics.Typeface)

Example 39 with Typeface

use of android.graphics.Typeface in project Print by johnkil.

the class TypefaceManager method load.

/**
     * Load a typeface from the specified font data.
     *
     * @param assets The application's asset manager.
     * @param path   The file name of the font data in the assets directory.
     */
static Typeface load(AssetManager assets, String path) {
    synchronized (sTypefaces) {
        Typeface typeface;
        if (sTypefaces.containsKey(path)) {
            typeface = sTypefaces.get(path);
        } else {
            typeface = Typeface.createFromAsset(assets, path);
            sTypefaces.put(path, typeface);
        }
        return typeface;
    }
}
Also used : Typeface(android.graphics.Typeface)

Example 40 with Typeface

use of android.graphics.Typeface in project Android-Iconics by mikepenz.

the class IconicsTypefaceSpan method applyCustomTypeFace.

private static void applyCustomTypeFace(Paint paint, Typeface tf) {
    int oldStyle;
    Typeface old = paint.getTypeface();
    if (old == null) {
        oldStyle = 0;
    } else {
        oldStyle = old.getStyle();
    }
    int fake = oldStyle & ~tf.getStyle();
    if ((fake & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }
    if ((fake & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }
    paint.setTypeface(tf);
}
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