// Path: support/src/main/java/net/avenwu/support/util/TypefaceContextWrapper.java
// public class TypefaceContextWrapper extends ContextWrapper {
//     private TypefaceLayoutInflator mInflater;
// 
//     public TypefaceContextWrapper(Context base) {
//         super(base);
//     }
// 
//     public static ContextWrapper wrap(Context base) {
//         return new TypefaceContextWrapper(base);
//     }
// 
//     @Override
//     public Object getSystemService(String name) {
//         if (LAYOUT_INFLATER_SERVICE.equals(name)) {
//             if (mInflater == null) {
//                 mInflater = new TypefaceLayoutInflator(LayoutInflater.from(getBaseContext()), this);
//             }
//             return mInflater;
//         }
//         return super.getSystemService(name);
//     }
// }
// 
// Path: support/src/main/java/net/avenwu/support/util/TypefaceUtils.java
// public class TypefaceUtils {
//     private static final Map<String, WeakReference<Typeface>> sCachedFonts = new HashMap<>();
// 
//     /**
//      * A helper loading a custom font.
//      *
//      * @param assetManager App's asset manager.
//      * @param filePath     The path of the file.
//      * @return Return {@link android.graphics.Typeface} or null if the path is invalid.
//      */
//     public static Typeface load(final AssetManager assetManager, final String filePath) {
//         synchronized (sCachedFonts) {
//             try {
//                 if (!sCachedFonts.containsKey(filePath) || sCachedFonts.get(filePath).get() == null) {
//                     final Typeface typeface = Typeface.createFromAsset(assetManager, filePath);
//                     sCachedFonts.put(filePath, new WeakReference<Typeface>(typeface));
//                     return typeface;
//                 }
//             } catch (Exception e) {
//                 Log.w("Calligraphy", "Can't create asset from " + filePath + ". Make sure you have passed in the correct path and file name.", e);
//                 sCachedFonts.put(filePath, null);
//                 return null;
//             }
//             return sCachedFonts.get(filePath).get();
//         }
//     }
// 
//     public static void setTypeface(Context context, TextView textView, String filePath) {
//         if (textView == null || context == null) return;
//         textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
//         textView.setTypeface(load(context.getAssets(), filePath));
//     }
// }


import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import net.avenwu.support.util.TypefaceContextWrapper;
import net.avenwu.support.util.TypefaceUtils;
package com.avenwu.deepinandroid;



public class TypefaceActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_typeface);
        //1. 直接设置TextView setTypeface
        final Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Oswald-Stencbab" +
// Path: support/src/main/java/net/avenwu/support/util/TypefaceContextWrapper.java
// public class TypefaceContextWrapper extends ContextWrapper {
//     private TypefaceLayoutInflator mInflater;
// 
//     public TypefaceContextWrapper(Context base) {
//         super(base);
//     }
// 
//     public static ContextWrapper wrap(Context base) {
//         return new TypefaceContextWrapper(base);
//     }
// 
//     @Override
//     public Object getSystemService(String name) {
//         if (LAYOUT_INFLATER_SERVICE.equals(name)) {
//             if (mInflater == null) {
//                 mInflater = new TypefaceLayoutInflator(LayoutInflater.from(getBaseContext()), this);
//             }
//             return mInflater;
//         }
//         return super.getSystemService(name);
//     }
// }
// 
// Path: support/src/main/java/net/avenwu/support/util/TypefaceUtils.java
// public class TypefaceUtils {
//     private static final Map<String, WeakReference<Typeface>> sCachedFonts = new HashMap<>();
// 
//     /**
//      * A helper loading a custom font.
//      *
//      * @param assetManager App's asset manager.
//      * @param filePath     The path of the file.
//      * @return Return {@link android.graphics.Typeface} or null if the path is invalid.
//      */
//     public static Typeface load(final AssetManager assetManager, final String filePath) {
//         synchronized (sCachedFonts) {
//             try {
//                 if (!sCachedFonts.containsKey(filePath) || sCachedFonts.get(filePath).get() == null) {
//                     final Typeface typeface = Typeface.createFromAsset(assetManager, filePath);
//                     sCachedFonts.put(filePath, new WeakReference<Typeface>(typeface));
//                     return typeface;
//                 }
//             } catch (Exception e) {
//                 Log.w("Calligraphy", "Can't create asset from " + filePath + ". Make sure you have passed in the correct path and file name.", e);
//                 sCachedFonts.put(filePath, null);
//                 return null;
//             }
//             return sCachedFonts.get(filePath).get();
//         }
//     }
// 
//     public static void setTypeface(Context context, TextView textView, String filePath) {
//         if (textView == null || context == null) return;
//         textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
//         textView.setTypeface(load(context.getAssets(), filePath));
//     }
// }


// Path: sample/src/main/java/com/avenwu/deepinandroid/TypefaceActivity.java
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import net.avenwu.support.util.TypefaceContextWrapper;
import net.avenwu.support.util.TypefaceUtils;

package com.avenwu.deepinandroid;



public class TypefaceActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_typeface);
        //1. 直接设置TextView setTypeface
        final Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Oswald-Stencbab" +
            ".ttf");