Create a SpannableString
object and pass the font path from asset. Check the working below
SpannableString toolbarTitle = new SpannableString(getActionBar().getTitle());
String toolbarFont = getResources().getString(R.string.circular_bold);
CustomTypefaceSpan toolbarTypefaceSpan = new CustomTypefaceSpan(toolbarFont, this);
toolbarTitle.setSpan(toolbarTypefaceSpan, 0, toolbarTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
getActionBar().setTitle(toolbarTitle);
Here, R.string.circular_bold
is
<string name="circular_bold">font/CircularStd-Bold.ttf</string>
And font is in Asset/font
folder as displayed in image below

Below CustomFontHelper
class helps to set Typeface
to the text element-
public class CustomFontHelper {
/**
* Changing font of Paint element
* @param paint text element of which font needs to be changed
* @param font
* @param context
*/
public static void setCustomFont(Paint paint, String font, Context context) {
if (font == null) {
return;
}
Typeface typeface = FontCache.get(font, context);
if (typeface != null) {
paint.setTypeface(typeface);
}
}
}
CustomTypefaceSpan
class is the actual class where font is applied to the text element.
public class CustomTypefaceSpan extends TypefaceSpan {
private String font;
private Context context;
public CustomTypefaceSpan(@NonNull String font, @NonNull Context context) {
super("");
this.font = font;
this.context = context;
}
@Override
public void updateDrawState(TextPaint ds) {
CustomFontHelper.setCustomFont(ds, font, context);
}
@Override
public void updateMeasureState(TextPaint paint) {
CustomFontHelper.setCustomFont(paint, font, context);
}
}
FontCache
class is for caching the font, so same font can be reused
public class FontCache {
private static Hashtable<String, Typeface> fontCache = new Hashtable<>();
/**
* Gets the typeface from Asset folder
* @param name path to the font within asset folder
* @param context context of the view
* @return
*/
public static Typeface get(String name, Context context) {
Typeface tf = fontCache.get(name);
if (tf == null) {
try {
tf = Typeface.createFromAsset(context.getAssets(), name);
} catch (Exception e) {
return null;
}
fontCache.put(name, tf);
}
return tf;
}
}