chrisjenx / Calligraphy

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

Not working in Lollipop and AppCompat library #84

Closed ruqqq closed 9 years ago

ruqqq commented 10 years ago

On Android 4.4 with AppCompat Library, Calligraphy 1.1.+ doesn't work. However, Calligraphy 0.7.+ works fine.

On Android 5.0 with AppCompat Libary, both Calligraphy 1.1.+ and 0.7.+ does not seem to work.

chrisjenx commented 10 years ago

@ruqqq you won't need the work around with support-v4:21 + fragments when using 1.2.1 That was the point.

Me and @dlew have been discussing a better way to handle this all together. This branch will stay as is until we decide how to proceed.

jpozo20 commented 10 years ago

For me it's not working either way. Tried the 1.2.0 and the getLayoutInflater(), nothing. Tried using the snapshot, and still nothing.

gabrielittner commented 10 years ago

The snapshot produces some errors in the log when AppCompat isn't included (I'm just using it because it fixes the textAllCaps issue on 5.0)

11-14 14:21:58.134    4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.isActionBarSubTitle
11-14 14:21:58.144    4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.isActionBarTitle
11-14 14:21:58.144    4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.parentIsToolbarV7
11-14 14:21:58.144    4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreated

Not sure if there is really a problem, just wanted to let you know.

chrisjenx commented 10 years ago

Thats fine, thats the runtime warning you that it couldn't find the classes that we are checking for.

On Thu Nov 13 2014 at 12:32:41 PM Gabriel Ittner notifications@github.com wrote:

The snapshot produces some errors in the log when AppCompat isn't included 11-14 14:21:58.134 4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.isActionBarSubTitle 11-14 14:21:58.144 4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.isActionBarTitle 11-14 14:21:58.144 4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.parentIsToolbarV7 11-14 14:21:58.144 4215-4215/com.appgenix.bizcal.debug E/dalvikvm﹕ Could not find class 'android.support.v7.widget.Toolbar', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreated

Not sure if there is really a problem, just wanted to let you know.

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

gabrielittner commented 10 years ago

This appcompat issue is still caused by Calligraphy with the updated appcompat version https://code.google.com/p/android/issues/detail?id=77691 As soon as I remove the attachBaseContext method the issue disappears, so it seems like the CalligraphyContextWrapper breaks something.

chrisjenx commented 10 years ago

Gabriel looks like you are using the wrong base theme for appcompat-v21 in that bug you raised. also we know there is an issue with Tinting, its actually been raised in this issue: #92

On Wed Nov 19 2014 at 12:05:44 AM Gabriel Ittner notifications@github.com wrote:

This appcompat issue is still caused by Calligraphy with the updated appcompat version https://code.google.com/p/android/issues/detail?id=77691 As soon as I remove the attachBaseContext method the issue disappears, so it seems like the CalligraphyContextWrapper breaks something.

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

gabrielittner commented 10 years ago

What is wrong with @style/Theme.AppCompat.Light.NoActionBar?

jophde commented 10 years ago

Is this still an issue with new versions of the support libraries and app compat that just came out the other day? (21.0.2)

chrisjenx commented 10 years ago

I would assume so. It's the tinting stuff that broke calligraphy. Which is still present.

On Thu, 20 Nov 2014 18:57 Joshua Deffibaugh notifications@github.com wrote:

Is this still an issue with new versions of the support libraries and app compat that just came out the other day? (21.0.2)

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

jophde commented 10 years ago

Particularly, the issue with Google cloning in the Fragment Manager?

chrisjenx commented 10 years ago

Yes, but the problem is quite complicated. And not 100% yet, thus the snapshot. I'm working in another branch for a better overall solution.

On Thu, 20 Nov 2014 21:01 Joshua Deffibaugh notifications@github.com wrote:

Particularly, the issue with Google cloning in the Fragment Manager?

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

chrisjenx commented 10 years ago

101 (Snapshot-2.0.0) Approaches this problem slightly differently I would appreciate people looking at the snapshot to give some feedback.

davidgarciaanton commented 10 years ago

@chrisjenx Just giving feedback, it seems Snapshot 2.0.0 is working, just added it to my project, and seems it's working fine to me.

Thanks for the great work!

chrisjenx commented 10 years ago

Thanks for the feedback. There will be some api change on the snapshot so be aware.

On Fri, 5 Dec 2014 16:32 David García notifications@github.com wrote:

@chrisjenx https://github.com/chrisjenx Just giving feedback, it seems Snapshot 2.0.0 is working, just added it to my project, and seems it's working fine to me.

Thanks for the great work!

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

thearaks commented 9 years ago

Hi @chrisjenx, I'm testing Snapshot 2.0.0. Everything seems ok, except some strange warnings when inflating options menus (might be support SearchView widget):

01-09 03:37:14.340    7137-7137/it.codeatlas.android.veecards W/Calligraphy﹕ Can't create asset from res/drawable-ldpi-v4/search_plate.9.png. Make sure you have passed in the correct path and file name.
    java.lang.RuntimeException: Font asset not found res/drawable-ldpi-v4/search_plate.9.png
            at android.graphics.Typeface.createFromAsset(Typeface.java:190)
            at uk.co.chrisjenx.calligraphy.TypefaceUtils.load(TypefaceUtils.java:34)
            at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:112)
            at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:141)
            at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreatedInternal(CalligraphyFactory.java:173)
            at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreated(CalligraphyFactory.java:131)
            at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:170)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
            at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:146)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
            at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.support.v7.widget.SearchView.<init>(SearchView.java:282)
            at android.support.v7.widget.SearchView.<init>(SearchView.java:268)
            at android.support.v7.widget.SearchView.<init>(SearchView.java:264)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
            at android.support.v7.internal.view.SupportMenuInflater$MenuState.newInstance(SupportMenuInflater.java:499)
            at android.support.v7.internal.view.SupportMenuInflater$MenuState.setItem(SupportMenuInflater.java:458)
            at android.support.v7.internal.view.SupportMenuInflater$MenuState.addItem(SupportMenuInflater.java:479)
            at android.support.v7.internal.view.SupportMenuInflater.parseMenu(SupportMenuInflater.java:196)
            at android.support.v7.internal.view.SupportMenuInflater.inflate(SupportMenuInflater.java:118)
            at it.codeatlas.android.veecards.NavigationActivity.onCreateOptionsMenu(NavigationActivity.java:484)
            at android.app.Activity.onCreatePanelMenu(Activity.java:2820)
            at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:275)
            at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:276)
            at android.support.v7.app.ActionBarActivityDelegate$1.onCreatePanelMenu(ActionBarActivityDelegate.java:79)
            at android.support.v7.widget.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:49)
            at android.support.v7.internal.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:459)
            at android.support.v7.internal.app.ToolbarActionBar$1.run(ToolbarActionBar.java:69)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Thank you! Great lib!

chrisjenx commented 9 years ago

Looks like you are passing in a drawable instead of a font path. Can you share the XML?

On Mon, 12 Jan 2015 08:55 thearaks notifications@github.com wrote:

Hi @chrisjenx https://github.com/chrisjenx, I'm testing Snapshot 2.0.0. Everything seems ok, except some strange warnings when inflating options menus (might be support SearchView widget):

01-09 03:37:14.340 7137-7137/it.codeatlas.android.veecards W/Calligraphy﹕ Can't create asset from res/drawable-ldpi-v4/search_plate.9.png. Make sure you have passed in the correct path and file name. java.lang.RuntimeException: Font asset not found res/drawable-ldpi-v4/search_plate.9.png at android.graphics.Typeface.createFromAsset(Typeface.java:190) at uk.co.chrisjenx.calligraphy.TypefaceUtils.load(TypefaceUtils.java:34) at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:112) at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:141) at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreatedInternal(CalligraphyFactory.java:173) at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreated(CalligraphyFactory.java:131) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:170) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:146) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.support.v7.widget.SearchView.(SearchView.java:282) at android.support.v7.widget.SearchView.(SearchView.java:268) at android.support.v7.widget.SearchView.(SearchView.java:264) at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.support.v7.internal.view.SupportMenuInflater$MenuState.newInstance(SupportMenuInflater.java:499) at android.support.v7.internal.view.SupportMenuInflater$MenuState.setItem(SupportMenuInflater.java:458) at android.support.v7.internal.view.SupportMenuInflater$MenuState.addItem(SupportMenuInflater.java:479) at android.support.v7.internal.view.SupportMenuInflater.parseMenu(SupportMenuInflater.java:196) at android.support.v7.internal.view.SupportMenuInflater.inflate(SupportMenuInflater.java:118) at it.codeatlas.android.veecards.NavigationActivity.onCreateOptionsMenu(NavigationActivity.java:484) at android.app.Activity.onCreatePanelMenu(Activity.java:2820) at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:275) at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:276) at android.support.v7.app.ActionBarActivityDelegate$1.onCreatePanelMenu(ActionBarActivityDelegate.java:79) at android.support.v7.widget.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:49) at android.support.v7.internal.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:459) at android.support.v7.internal.app.ToolbarActionBar$1.run(ToolbarActionBar.java:69) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Thank you! Great lib!

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

thearaks commented 9 years ago

@chrisjenx I'm afraid I can't, I verified that the menu item causing the warning is the support SearchView. The XML is from the standard support v7 SearchView layout...

chrisjenx commented 9 years ago

Very odd. OK I'll see if I can look into or

On Mon, 12 Jan 2015 09:26 thearaks notifications@github.com wrote:

@chrisjenx https://github.com/chrisjenx I'm afraid I can't, I verified that the menu item causing the warning is the support SearchView. The XML is from the standard support v7 SearchView layout...

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

chrisjenx commented 9 years ago

@thearaks this seems related to #114. I'm going to close this. If you add any information to that issue.

chrisjenx commented 9 years ago

The OP issue has been fixed in upcoming 2.0.0.

emce commented 9 years ago

I'm using 2.0.2, and it's not crashing the app, but from logcat, I get an error: Could not find class 'android.support.v7.widget.Toolbar', referenced from method...

chrisjenx commented 9 years ago

That's normal. It's just looking for the Toolbar. And your not compiling your app with it.

On Fri, 6 Mar 2015 08:03 Michał Ćwikliński notifications@github.com wrote:

I'm using 2.0.2, and it's not crashing the app, but from logcat, I get an error: Could not find class 'android.support.v7.widget.Toolbar', referenced from method...

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

mineshpatel1511 commented 9 years ago

@chrisjenx I hear you saying these errors mean nothing

Could not find class 'android.support.v7.widget.Toolbar', referenced from method ...isActionBarSubTitle Could not find class 'android.support.v7.widget.Toolbar', referenced from method ...isActionBarTitle Could not find class 'android.support.v7.widget.Toolbar', referenced from method ...parentIsToolbarV7 Could not find class 'android.support.v7.widget.Toolbar', referenced from method ...onViewCreated

but whenever I see these errors, I see the fonts getting changed in the app. The use case is the app is not in memory and opened through a deep link. I am on "com.android.support:support-v4:21.+" and Kitkat 4.4. I am on "uk.co.chrisjenx:calligraphy:1.2.+" for calligraphy.

chrisjenx commented 9 years ago

@mineshpatel1511 correct, you would need the v7 support library compile in the app. This is normal. See the Calligraphy example .

mineshpatel1511 commented 9 years ago

@chrisjenx I am wondering why does it need the v7 support only in few cases and not in all cases?

chrisjenx commented 9 years ago

You do NOT need the v7 support if you don't use it. The warnings in the logs are normal. It's that I have referenced the classes but ART/Dalvik can't find them. This is normal and safe to ignore. The Library checks if they are provided and won't check if they are not.

rraallvv commented 5 years ago

Does anyone know why importing the folder CalligraphySample fails on AndroidStudio? Should I import the full repository?

chrisjenx commented 5 years ago

I think the Sample imports the lib directly intead of maven, you probably need to checkout the whole project.

rraallvv commented 5 years ago

@chrisjenx I'll give it a try. Thanks.