Q:

TextAllcaps issue

Good Afternoon.
I have implemented TabLayout with viewpager when tab title text is in .ttf format font not working.
I have done Style code, but I'm facing the same problem.
see my xml code ->   
 <android.support.design.widget.TabLayout
 android:id="@+id/tabs"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 style="@style/CustomTabLayout"
 android:background="#eceff1"
 app:tabMode="fixed"
 app:tabGravity="fill"/>    

style code ->  
<style name="CustomTabLayout" parent="Widget.Design.TabLayout">
 <item name="tabIndicatorColor">@color/iconGray</item>
 <item name="tabIndicatorHeight">3dp</item>
 <item name="tabBackground">?attr/selectableItemBackground</item>
 <item name="tabTextAppearance">@style/CustomTabTextAppearance</item>
 <item name="tabSelectedTextColor">@color/colorPrimary</item>
</style>

<style name="CustomTabTextAppearance" parent="TextAppearance.Design.Tab">
 <item name="android:textSize">@dimen/txt_15</item>
 <item name="android:textColor">#a4dbb2</item>
 <item name="android:fontFamily">@font/amaranth</item>
 <item name="textAllCaps">true</item>
</style>

I have seen the "questions that may already have your answer", but 
I'm not satisfied with those answers
Thank you in advance...

A:

MyClass.java -
public class MyClass extends Application {

  @Override
  public void onCreate() {
    TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
  }
}

themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="MyAppTheme" parent="@android:style/Theme.Holo.Light">
    <!-- you should set typeface which you want to override with TypefaceUtil -->
    <item name="android:typeface">serif</item>
  </style>
</resources>

TypefaceUtil.java -
import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;

import java.lang.reflect.Field;

public class TypefaceUtil {

    /**
     * Using reflection to override default typeface
     * NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN
     * @param context to work with assets
     * @param defaultFontNameToOverride for example "monospace"
     * @param customFontFileNameInAssets file name of the font from assets
     */
    public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) {
        try {
            final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets);

            final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride);
            defaultFontTypefaceField.setAccessible(true);
            defaultFontTypefaceField.set(null, customFontTypeface);
        } catch (Exception e) {
            Log.e("Can not set custom font " + customFontFileNameInAssets + " instead of " + defaultFontNameToOverride);
        }
    }
}

