Java源码示例:com.norbsoft.typefacehelper.TypefaceCollection

示例1
private void initLibs() {

        // Initialize dagger
        DaggerManager.getInstance().buildComponentAndInject(this);

        //@formatter:off
        // Initialize typeface helper
        TypefaceCollection typeface = new TypefaceCollection.Builder()
                .set(Typeface.NORMAL, Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf"))
                .set(Typeface.BOLD, Typeface.createFromAsset(getAssets(), "fonts/Roboto-Medium.ttf"))
                .create();
        TypefaceHelper.init(typeface);
        //@formatter:on

        if (BuildConfig.DEBUG) {
            // Facebook Stetho
            Stetho.initializeWithDefaults(this);
        }
    }
 
示例2
protected void setupTypeFace() {
  TypefaceHelper.init(new TypefaceCollection.Builder()
      .set(Typeface.NORMAL, createTypefaceFromAsset(R.string.font_ubuntu_regular))
      .set(Typeface.BOLD, createTypefaceFromAsset(R.string.font_ubuntu_bold))
      .set(Typeface.ITALIC, createTypefaceFromAsset(R.string.font_ubuntu_regular_italic))
      .set(Typeface.BOLD_ITALIC,
          createTypefaceFromAsset(R.string.font_ubuntu_bold_italic))
      .create());
}
 
示例3
@Override public void onCreate() {
	super.onCreate();

	// Load helper with default custom typeface (single custom typeface)
	TypefaceHelper.init(new TypefaceCollection.Builder()
			.set(Typeface.NORMAL, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-R.ttf"))
			.set(Typeface.BOLD, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-B.ttf"))
			.set(Typeface.ITALIC, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-RI.ttf"))
			.set(Typeface.BOLD_ITALIC, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-BI.ttf"))
			.create());

	// Multiple custom typefaces support
	mJuiceTypeface = new TypefaceCollection.Builder()
			.set(Typeface.NORMAL, Typeface.createFromAsset(getAssets(), "fonts/Juice/JUICE_Regular.ttf"))
			.set(Typeface.BOLD, Typeface.createFromAsset(getAssets(), "fonts/Juice/JUICE_Bold.ttf"))
			.set(Typeface.ITALIC, Typeface.createFromAsset(getAssets(), "fonts/Juice/JUICE_Italic.ttf"))
			.set(Typeface.BOLD_ITALIC, Typeface.createFromAsset(getAssets(), "fonts/Juice/JUICE_Bold_Italic.ttf"))
			.create();

	// Multiple custom typefaces support
	mArchRivalTypeface = new TypefaceCollection.Builder()
			.set(Typeface.NORMAL, Typeface.createFromAsset(getAssets(), "fonts/arch_rival/SF_Arch_Rival.ttf"))
			.set(Typeface.BOLD, Typeface.createFromAsset(getAssets(), "fonts/arch_rival/SF_Arch_Rival_Bold.ttf"))
			.set(Typeface.ITALIC, Typeface.createFromAsset(getAssets(), "fonts/arch_rival/SF_Arch_Rival_Italic.ttf"))
			.set(Typeface.BOLD_ITALIC, Typeface.createFromAsset(getAssets(), "fonts/arch_rival/SF_Arch_Rival_Bold_Italic.ttf"))
			.create();

	// Multiple custom typefaces support
	mActionManTypeface = new TypefaceCollection.Builder()
			.set(Typeface.NORMAL, Typeface.createFromAsset(getAssets(), "fonts/Action-Man/Action_Man.ttf"))
			.set(Typeface.BOLD, Typeface.createFromAsset(getAssets(), "fonts/Action-Man/Action_Man_Bold.ttf"))
			.set(Typeface.ITALIC, Typeface.createFromAsset(getAssets(), "fonts/Action-Man/Action_Man_Italic.ttf"))
			.set(Typeface.BOLD_ITALIC, Typeface.createFromAsset(getAssets(), "fonts/Action-Man/Action_Man_Bold_Italic.ttf"))
			.create();

	// Multiple custom typefaces support
	mUbuntuTypeface = new TypefaceCollection.Builder()
			.set(Typeface.NORMAL, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-R.ttf"))
			.set(Typeface.BOLD, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-B.ttf"))
			.set(Typeface.ITALIC, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-RI.ttf"))
			.set(Typeface.BOLD_ITALIC, Typeface.createFromAsset(getAssets(), "fonts/ubuntu/Ubuntu-BI.ttf"))
			.create();

	// Multiple custom typefaces support
	mSystemDefaultTypeface = TypefaceCollection.createSystemDefault();
}
 
示例4
/** Multiple custom typefaces support */
public TypefaceCollection getJuiceTypeface() {
	return mJuiceTypeface;
}
 
示例5
/** Multiple custom typefaces support */
public TypefaceCollection getArchRivalTypeface() {
	return mArchRivalTypeface;
}
 
示例6
/** Multiple custom typefaces support */
public TypefaceCollection getActionManTypeface() {
	return mActionManTypeface;
}
 
示例7
/** Multiple custom typefaces support */
public TypefaceCollection getSystemDefaultTypeface() {
	return mSystemDefaultTypeface;
}
 
示例8
/** Multiple custom typefaces support */
public TypefaceCollection getUbuntuTypeface() {
	return mUbuntuTypeface;
}