Bug 51427 - Custom Font Not Working Inside NavigationPage
Summary: Custom Font Not Working Inside NavigationPage
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
Depends on:
Reported: 2017-01-11 21:47 UTC by Jimmy [MSFT]
Modified: 2017-09-12 12:09 UTC (History)
10 users (show)

Tags: uwp, ac, font, fr
Is this bug a regression?: ---
Last known good build:

repro solution (783.17 KB, application/zip)
2017-01-11 21:47 UTC, Jimmy [MSFT]

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:

Description Jimmy [MSFT] 2017-01-11 21:47:59 UTC
Created attachment 19236 [details]
repro solution

### Overview 
On UWP, a custom font set on a Label does not work when if the page is inside a NavigationPage. It works fine when the page is the root MainPage.

Other observations:
- This issue does not occur when using a TabbedPage or MasterDetailPage
- Also happens on pages navigated to and back to
- iOS and Android do not have this issue

### Steps to Reproduce
1. Run the attached UWP project

### Expected Results
The Label will have a custom font. To see the expected results, in App.cs uncomment line 13 and comment line 16.

### Actual Results 
The Label does not have a custom font

### Testing Info
Tested with Forms and Forms 2.2
Comment 1 Jimmy [MSFT] 2017-01-18 16:54:57 UTC
Just noting that this also happens on WP 8.1 so it's not limited to just UWP and it still happens on Forms 2.3.4-pre1
Comment 2 Jimmy [MSFT] 2017-01-29 21:01:26 UTC
See PR: https://github.com/xamarin/Xamarin.Forms/pull/730

### Workaround
Include a leading '/' in your font path, e.g. from the Working with Fonts sample:

> "/Assets/Fonts/Lobster-Regular.ttf#Lobster"
Comment 3 Paul Johnson 2017-08-16 13:48:16 UTC
The workaround doesn't seem to fix the issue if you're not using XAML, but setting the FontFamily directly in code

(for example

var font = string.Empty;
if (Device.RuntimePlatform == Device.Windows)
 font = "/Assets/Fonts/MyFont.ttf#MyFont";
 font = "MyFont.ttf#MyFont";

var myLbl = new Label
   FontFamily = font,
   FontSize = 16,
   Text = "Hello Xamarin"
Comment 4 Rui Marinho 2017-09-12 12:09:21 UTC
Should be fixed on 2.4.1-pre1