nwestfall / calligraphy.xamarin Goto Github PK
View Code? Open in Web Editor NEWUse custom fonts in Android! Port of https://github.com/InflationX/Calligraphy
License: Apache License 2.0
Use custom fonts in Android! Port of https://github.com/InflationX/Calligraphy
License: Apache License 2.0
Tries to add another factory when cloning.
hi; thank for your job
but still not work in for example samsung note3 android 5.0 and nokia and many huawi devices
Still having an issue with an app that won't change the font. Works with binding, but not this port. Will be adding logging to see how it runs.
After updating to the latest Nuget release with Android 10 support, one of the workflows in our app was experiencing a crash with the following stacktrace:
ERROR : System.InvalidCastException: Specified cast is not valid.
at Calligraphy.Xamarin.CalligraphyFactory.OnViewCreatedInternal (Android.Views.View view, Android.Content.Context context, Android.Util.IAttributeSet attrs) [0x000db] in <636ad58454d34da899ec75f85f329bd1>:0
at Calligraphy.Xamarin.CalligraphyFactory.OnViewCreated (Android.Views.View view, Android.Content.Context context, Android.Util.IAttributeSet attrs) [0x00026] in <636ad58454d34da899ec75f85f329bd1>:0
at Calligraphy.Xamarin.CalligraphyLayoutInflater.OnCreateView (System.String name, Android.Util.IAttributeSet attrs) [0x0004d] in <636ad58454d34da899ec75f85f329bd1>:0
at Android.Views.LayoutInflater.n_OnCreateView_Ljava_lang_String_Landroid_util_AttributeSet_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_name, System.IntPtr native_attrs) [0x00017] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.35(intptr,intptr,intptr,intptr)
I did some digging and found the culprit:
Calligraphy.Xamarin/Calligraphy.Xamarin/CalligraphyFactory.cs
Lines 152 to 153 in 6d125bf
In my case, we had some custom views of type Android.Views.View
which it was trying to cast into a Android.Support.V7.Widget.Toolbar
.
Because IsAssignableFrom()
returns true
when the current type is in the same hierarchy as the given type, a custom view of type Android.Views.View
will pass the type check since Android.Support.V7.Widget.Toolbar
inherits from Android.Views.View
. I wasn't sure if there was a reason why the type check is being performed with IsAssignableFrom()
specifically, since everywhere else in the function it just uses the is
operator.
Because of this, I've made two PRs which both fix this issue but in different ways:
#11
#12
#11 changes the type checking implementation to just use the is
operator and check it against the Toolbar
type explicitly.
#12 is a more conservative fix which will just catch the exception if it's thrown, and then skip that view. This does not change the type checking implementation and still utilizes IsAssignableFrom()
if that is to be preserved.
Whichever PR is more suitable is up to you and you're free to close the other ๐
I already saw some small changes... Want to make sure libraries are in sync.
Hi, i was using your package and had no problems till this updagre.
AFter this upgrade started to have some diferences bettwen the old version, before upgrade, and the new version, after upgrade.
Can u please help me?
Hi,
I switched to using your project after I had to upgrade my project to API Level 29. I was previously using Callygraphy.Xamarin, which I believe is deprecated and doesn't support Android 10.
My project builds but I don't see my fonts coming up. I even added the config code to OnCreate() per your instructions. Is this a drop-in replacement or do I have to make more code changes? All of my fonts are under my projects "Asset/fonts" folder.
Thanks,
Jeff
Works in test app, but not in another app with custom styles
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.