Bug 31472 - Changing FontFamily on label in Android does not work.
Summary: Changing FontFamily on label in Android does not work.
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.4
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-29 13:11 UTC by Andy
Modified: 2016-09-28 10:43 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Andy 2015-06-29 13:11:07 UTC
When we create a button or label in Xamarin Forms and set a new FontFamily, the font fails to load. It works on iOS, and we have had to write our own CustomFontLabel to get around this. Perhaps our folder structure is not set up properly? These fonts are in Assets/Fonts

We have to make our own custom class with a custom renderer in order to load these fonts. 		
                void UpdateFont()
		{
			if(label != null && originalLabel != null)
			{
				Typeface font = Typeface.CreateFromAsset (Forms.Context.Assets, Styles.FontOpenSansBold);
				label.Typeface = font;
			}
		}


public static readonly string FontOpenSansBold = 		Device.OnPlatform(/* iOS */ "OpenSans-Bold", /* Android */ "Fonts/OpenSans-Bold.ttf", /* WindowsPhone */ null);
Comment 1 Rui Marinho 2015-07-01 11:32:10 UTC
Hi Andy, Xamarin.Forms for Android does not currently expose the ability to set the font to a custom font file, so custom renderers are required. So this is a known limitation.

This is also documented here :
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/fonts/#Android

Thanks
Regards
Xamarin Forms team
Comment 2 Sheetal 2016-09-28 10:43:11 UTC
Is this issue fixed in latest upgrade?