Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Android module for easy using a custom fonts in the app

Notifications You must be signed in to change notification settings

mobiledevpro/fontcustomizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fontcustomizer

Android module for easy using a custom fonts in the project

How to use:

  • Project -> New -> Module -> Import Gradle Project
  • add dependency to build.gradle
dependencies {

....

compile project(':fontcustomizer');
}
  • put your [font-file].ttf files into app/src/main/assets/fonts;
  • in onCreate() method (of Application or Activity or Fragment) call this for caching all names of the fonts located in the assets/fonts:
        FontCache.getInstance(getApplicationContext());

or call this for each .ttf for caching a custom names of the fonts:

        FontCache.getInstance(getApplicationContext()).addFont("any-name", "[font-file].ttf");
  • apply font:
textView.setTypeface(
    FontCache.getInstance(getApplicationContext()).get("any-name")
);

Example:

public class AppController extends Application{

    @Override
    public void onCreate() {
        super.onCreate();
        Context context = getApplicationContext();

        //Add custom font to HashMap
        FontCache.getInstance(context).addFont("regular", "SourceSansPro-Regular.ttf");
        FontCache.getInstance(context).addFont("semibold", "SourceSansPro-Semibold.ttf");
        FontCache.getInstance(context).addFont("light", "SourceSansPro-Light.ttf");
    }
    
}  

About

Android module for easy using a custom fonts in the app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages