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);
}
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);
}
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);
}
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;
}
}
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);
}
Aggregations