chrisjenx / Calligraphy

Custom fonts in Android the easy way...
Apache License 2.0
8.59k stars 1.09k forks source link

My font is set only the first time i run the app #250

Open candeiasdan opened 8 years ago

candeiasdan commented 8 years ago

If the app runs for the first time (after install) i can see my custom font. If now I stop the app and open it again the font is not being set.

on my BaseApplication class i have onCreate():

    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/CustomFont.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build());

MainActivity:

    @Override
     protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
     }

I have 3 different fonts inside my app. Whenever i need to use some specific font i do:

<TextView
        android:id="@+id/txtview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="A"
        android:textAllCaps="true"
        android:textColor="@color/black"
        fontPath="fonts/SourceSansPro-Light.ttf"
        />

Am i missing something? Debugging the app, every time i open the app it passes through onCreate() (BaseApplication class), attachBaseContext. What can be wrong here?

chrisjenx commented 8 years ago

What version of build tools etc are you using? Version of Android? Version of Calligraphy? etc..

candeiasdan commented 8 years ago

Android Studio 2.0 Preview 5 Gradle: com.android.tools.build:gradle:2.0.0-alpha5 Library version: uk.co.chrisjenx:calligraphy:2.1.0 BuildToolVersion: 23.0.2 CompileSdkVersion: 23 MinSdkVersion: 17 Pro guard: minifyEnabled false

chrisjenx commented 8 years ago

Using instant run?

On Wed, 17 Feb 2016, 18:23 candeiasdan notifications@github.com wrote:

Android Studio 2.0 Preview 5 Gradle: com.android.tools.build:gradle:2.0.0-alpha5 Library version: uk.co.chrisjenx:calligraphy:2.1.0 BuildToolVersion: 23.0.2 CompileSdkVersion: 23 MinSdkVersion: 17 Pro guard: minifyEnabled false

— Reply to this email directly or view it on GitHub https://github.com/chrisjenx/Calligraphy/issues/250#issuecomment-185335538 .

candeiasdan commented 8 years ago

No. Running the app for the first time everything works fine. Once i Stop it and re-open it, the fonts are gone.

chrisjenx commented 8 years ago

OK. Same issue with build tools 1.5 and release builds?

On Wed, 17 Feb 2016, 18:34 candeiasdan notifications@github.com wrote:

No. Running the app for the first time everything works fine. Once i Stop it and re-open it, the fonts are gone.

— Reply to this email directly or view it on GitHub https://github.com/chrisjenx/Calligraphy/issues/250#issuecomment-185340252 .

candeiasdan commented 8 years ago

Build tools: classpath 'com.android.tools.build:gradle:1.5.0' Build Variante: Release and debug.

Same problem.

chrisjenx commented 8 years ago

OK, Are you able to reproduce the issue in the sample app? I'm wondering if it's either the font or another library? Also are you testing on Android 5.0?

candeiasdan commented 8 years ago

Everything works fine in a sample app, starting and stopping, no problem. Testing on 4.4.4

As sample app made a ListView with two row types: 1) textview where i explicitly define font family 2) textview without font family Result: the calligraphy is applied to both layouts.

chrisjenx commented 8 years ago

@candeiasdan if it works in a sample app, this suggests something else is interfering. What else are you running in your app?