UXDivers / Gorilla-Player-Support

This is the public Gorilla Player support website
http://gorillaplayer.com
115 stars 17 forks source link

Crashing when attempting to use custom font #272

Open jt-github opened 6 years ago

jt-github commented 6 years ago

If I follow the standard Xamarin Forms instructions for using a custom font on Android: https://developer.xamarin.com/guides/xamarin-forms/user-interface/text/fonts/#Using_a_Custom_Font

And run an old-fashioned debug session on my emulator, the font renders as expected. When I try to preview the XAML page in Gorilla Player, it immediately crashes with the following error in the logs:

{"Sender":"System.AppDomain","When":"{0:01/24/18 10:24:24 -06:00}","Context":null,"ExceptionMessage":"Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown.","ExceptionType":"Android.Runtime.JavaProxyThrowable","ExceptionStackTrace":"\n --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---\nandroid.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object\n at Xamarin.Forms.Platform.Android.Platform+<>cDisplayClass66_0.b__0 () [0x00015] in :0 \n at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <8211f1f12f9e45838d631abf63e51c79>:0 \n at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr nativethis) [0x00008] in <8211f1f12f9e45838d631abf63e51c79>:0 \n at (wrapper dynamic-method) System.Object:98f3665d-61e8-4a35-a63c-fc1b376814d5 (intptr,intptr)\n\tat mono.java.lang.RunnableImplementor.n_run(Native Method)\n\tat mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)\n\tat android.os.Handler.handleCallback(Handler.java:733)\n\tat android.os.Handler.dispatchMessage(Handler.java:95)\n\tat android.os.Looper.loop(Looper.java:136)\n\tat android.app.ActivityThread.main(ActivityThread.java:5001)\n\tat java.lang.reflect.Method.invokeNative(Native Method)\n\tat java.lang.reflect.Method.invoke(Method.java:515)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)\n\tat dalvik.system.NativeStart.main(Native Method)\n","NonExceptionType":null,"IsTerminating":true,"level":"error","message":"Client reported error","timestamp":"2018-01-24T16:24:24.867Z"}

There is a mention of custom fonts in the Gorilla SDK documentation, but only a single mention without any details or examples. Custom fonts are built into Xamarin Forms, so I wouldn't think you'd need the SDK just to preview fonts. That being said, running my app using the SDK works fine and the font renders as expected!

I added FontAwesome.otf to my Assets folder, then created the following simple little label:

<Label Text="&#xF070;" >
  <Label.FontFamily>
    <OnPlatform x:TypeArguments="x:String">
      <On Platform="Android" Value="FontAwesome.otf#FontAwesome" />
    </OnPlatform>
  </Label.FontFamily>
</Label>

I'd attach a project, but this is easily reproduced.

If the regular Gorilla Player currently cannot render custom fonts, then it should definitely not cause a crash (with no helpful error message) but rather display the old "You need the SDK, Bro!" message instead. OK, maybe that's not the exact message, but you know what I mean.

michael-watson commented 6 years ago

surprised that something so common like FontAwesome isn't even being addressed

same issue I'm having

GetTheBalanceRight commented 6 years ago

I am also having this issue. Everything works fine on iOS, but as soon as a different font is used on Android, it's lights out. I am trying to use Roboto

cherici-simone commented 6 years ago

me too...same issue with FontAwesome...

uksreejith commented 6 years ago

Hi, I am also facing this exact same issue. Updated to gorilla version 1.2.2. Not seeing any difference. Please help!

jadenrogers commented 6 years ago

@jt-github

Works fine for both platforms. I use font awesome 5 free.

For Android add the ttf files to the "Assets" folder, build action should be AndroidAsset.

fa-brands-400.ttf fa-regular-400.ttf fa-solid-900.ttf

Use these strings in your project. I put mine in the App.xaml resources `

        <OnPlatform x:TypeArguments="x:String" x:Key="FontFontAwesomeBrands" iOS="FontAwesome5BrandsRegular" Android="fa-brands-400.ttf#FontAwesome5BrandsRegular"></OnPlatform>`

Example:

<Label Text="&#xf39e;" FontFamily="{StaticResource FontFontAwesomeBrands}"></Label>