Did something change from 2.3.1.114 to 2.3.3.180 with regard to Android fonts?

I have just upgraded to 2.3.3.180, and started to get crashes everywhere on Android regarding Custom Fonts.

Specifically, in our CustomLabelRenderer base.OnElementChanged call, we are seeing an unhandled exception "Java.Lang.RuntimeException: Font asset not found {fontname}".

I have found that if I strip the font name right back to its basic name (i.e. fontawesome.ttf instead of \assets\fonts\fontawesome.ttf) then the crash goes away, but this means a huge refactoring going back through thousands of lines of XAML to amend every font (for Android only).

It seems that suddenly Xamarin are trying to load the font for us instead of having to have a custom renderer, but it doesnt like the path names.

I changed the font names on a few pages to see if this actually worked now, and while the error goes away, the font doesnt actually get used, so im not sure what is trying to be achieved here...

Anyone else come across this?

Answers

  • NMackayNMackay GBInsider, University mod
    edited January 2017

    Sorry misread

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited January 2017

    @MercifulGiraffe said:
    this means a huge refactoring going back through thousands of lines of XAML to amend every font (for Android only).

    I would urge you to apply better practices to how you code. There is no reason you should have tons of specific references to fonts. You define a style in one place that references the font. Then you use the style throughout your markup. If you need to change fonts you do it on one place not thousands.

    Maybe there was a change to the Xamarin extension... Maybe there wasn't. But there will always be changes to something, someplace... Either your code, or a coworker, or a business rule from the bosses, or a third party extension. You have to code in a robust and maintainable way making use of good coding practices. Banging out bad code quickly is not a strategy.

  • MercifulGiraffeMercifulGiraffe USMember ✭✭

    Thanks for the link. This is very similar to what I implemented (yesterday) to get around this problem.

    Sometimes you inherit code that you need to deal with that is not ideal...

Sign In or Register to comment.