Bug 57417 - It can not preview a page with a custom font.
Summary: It can not preview a page with a custom font.
Status: CONFIRMED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Xamarin.Forms Previewer ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 57942 ()
Depends on:
Blocks:
 
Reported: 2017-06-12 23:25 UTC by Igor K.
Modified: 2018-03-07 09:38 UTC (History)
10 users (show)

Tags: bb ac vsmac vs
Is this bug a regression?: ---
Last known good build:


Attachments
Exception in the previewer. (116.02 KB, image/png)
2017-06-12 23:25 UTC, Igor K.
Details
Sample solution that reproduces the error (205.97 KB, application/x-zip-compressed)
2017-07-11 11:49 UTC, Henrik W.
Details


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 for Bug 57417 on Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.
Related Links:
Status:
CONFIRMED

Description Igor K. 2017-06-12 23:25:06 UTC
Created attachment 22844 [details]
Exception in the previewer.

Environment:

macincloud
Visual Studio Community 2017
Forms Project Support version 7.0.1

Create a simple Xamarin.Forms (PCL) project.

Try to use a custom font from Google - https://fonts.google.com/specimen/Tangerine

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:PersonalIncome3" x:Class="PersonalIncome3.PersonalIncome3Page">

    <Label Text="Welcome to Xamarin Forms!" 
        VerticalOptions="Center" HorizontalOptions="Center" 
        FontSize="40"
        FontFamily="Tangerine-Regular.ttf#Tangerine-Regular"
    />
    
</ContentPage>

In the iOS previewer everything ok.
In the Android(!) previewer I see an error. And it can't render the page.

System.NullReferenceException was thrown. Object reference not set to an instance of an object.

at Xamarin.Forms.Platform.Android.FontExtensions.ToTypeface 
... Xamarin.Forms.Platform.Android\Renderers\FontExtensions.cs:64

at Xamarin.Forms.Platform.Android.LabelRenderer.UpdateFont()
... Xamarin.Forms.Platform.Android\Renderers\LabelRenderer.cs:137

When I am running it in the Android emulator then it shows the label and font normally.
Comment 1 Mark McLemore 2017-07-10 23:34:49 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it.
Comment 2 Henrik W. 2017-07-11 11:46:43 UTC
Hi,
I also have the same problem. 
Here's a solution which produces the same problem. 
I added 2 pages to an out of the box Xamarin Forms PCL solution. The font has been added to both the iOS and the Android project.
When running in the emulator everything is dandy but the forms previewer for Android wont have it.

I didn't bother for any finesse: there are 2 pages: one using the iOS fontname and one using the droid fontname. The app goes to the droid version.

please help us!

Thanks!
Comment 3 Henrik W. 2017-07-11 11:49:22 UTC
Created attachment 23473 [details]
Sample solution that reproduces the error
Comment 4 Pierce Boggan [MSFT] 2017-07-11 14:37:47 UTC
Thanks so much for taking the time to submit this report! I can confirm using the latest Visual Studio 2017 Preview version 15.3 I am able to reproduce this issue. Marking this report as CONFIRMED.
Comment 5 Pierce Boggan [MSFT] 2017-07-11 15:32:05 UTC
*** Bug 57942 has been marked as a duplicate of this bug. ***