[forms-devel] Xamarin.Forms Android Custom Font Support
Roy Vousten
royvou at hotmail.com
Tue Jun 14 21:43:12 UTC 2016
Regarding performance
- Always load it as file
When loading of the assets fails, android will fail silently (return a default font). So there's not a good way to check this.
- Only check on dot.
As far as i know i haven't seen a font with a dot in the name so i think this would be a safe try (but we would prevent it from happening), also we wouldn't need to maintain a list of supported filetypes, but just let the developer do what he thinks would work. Maybe we should check if the dot isn't the first or last character since that could never happen (Just let it throw an exception) as safeguard.
Would be interesting to see the performance difference between those methods though.
Maybe there's another idea and i could make a quick performancetest locally.
But keep in mind this loading is done once per font, and afterwards cached so we shouldn't overdo it.
Roy
To: jason.smith at xamarin.com; royvou at hotmail.com
CC: forms-devel at lists.xamarin.com
From: bill.reiss at outlook.com
Subject: RE: [forms-devel] Xamarin.Forms Android Custom Font Support
Date: Tue, 14 Jun 2016 15:21:40 -0400
I like it, I have had times that the only reason I needed a custom renderer was to do custom fonts. This would help a lot.
Bill
Sent from my Windows 10 phone
From: Jason Smith
Sent: Tuesday, June 14, 2016 3:16 PM
To: Roy Vousten
Cc: forms-devel at lists.xamarin.com
Subject: Re: [forms-devel] Xamarin.Forms Android Custom Font Support
This is a great idea. So for performance reasons I wonder if we should simply check for a "." in the name and then assume its a file or if we should always attempt to load it as a file first then fall back when that fails.
On Tue, Jun 14, 2016 at 11:51 AM, Roy Vousten
<royvou at hotmail.com> wrote:
Hello Xamarin.Forms Community,
Why doesn't Xamarin.Forms support custom Font's for various controls on the Android Platform?
As a recap the current situation.
(https://developer.xamarin.com/guides/xamarin-forms/user-interface/text/fonts/):
iOS: Use the Font Name (Custom fonts that should be loaded are defined in info.plist).
Android: Create a Custom renderer or use the font name for a system font.
WP: Use filelocation # fontname for a custom font, or use the font name for a system font.
Something that could be implemented for Android so custom fonts is a supported feature across all platforms.
We could parse the FontFamily property to determine if it's an filelocation/filename [myawesomefont.ttf/myawesomefont.otf]. If it is, we should load the font from that location, otherwise it's a normal font and we should use the current way of loading a font.
It seems to be all that has to be changed is this:
https://github.com/royvou/Xamarin.Forms/blob/android-customfont/Xamarin.Forms.Platform.Android/Renderers/FontExtensions.cs
This shouldn't have a big impact on the codebase and not break existing apps.
Thoughts?
Roy
_______________________________________________
forms-devel mailing list
forms-devel at lists.xamarin.com
http://lists.ximian.com/mailman/listinfo/forms-devel
_______________________________________________
forms-devel mailing list
forms-devel at lists.xamarin.com
http://lists.ximian.com/mailman/listinfo/forms-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/forms-devel/attachments/20160614/42b4428b/attachment.html>
More information about the forms-devel
mailing list