Bug 29224 - [WinPhone] When using custom font Button and Entry don't calculate height properly when targeting WP 8.1
Summary: [WinPhone] When using custom font Button and Entry don't calculate height pro...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.4.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-04-18 10:22 UTC by Vladislav Kosev
Modified: 2015-05-01 18:56 UTC (History)
1 user (show)

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


Attachments
A sample project for repo (813.47 KB, application/octet-stream)
2015-04-18 11:15 UTC, Vladislav Kosev
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 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 Vladislav Kosev 2015-04-18 10:22:59 UTC

    
Comment 1 Vladislav Kosev 2015-04-18 11:09:52 UTC
When targeting WP 8.1, if you specify custom font which is included as Content in the project, the calculated height of the Button is incorrect (41 pixels). Since the height is set explicitly by Xamarin.Forms it seems that it doesn't take into account that the font loads asynchronously and doesn't update the height when the font loads. Entry exhibits the same behavior.

Also, if I create a button with the custom font in the main page of the WinPhone project and then put LoadApplication(new MobileListViewApp.App()) in its click handler, the heights are correct.

Currently I haven't found a workaround for this (will use one if you point it out until you fix it), but this is preventing me to go further with my project.

This works correctly when targeting WP 8.0 (the default).

I really need a workaround/fix for this!
Comment 2 Vladislav Kosev 2015-04-18 11:15:07 UTC
Created attachment 10812 [details]
A sample project for repo
Comment 3 Jon Goldberger [MSFT] 2015-05-01 18:17:14 UTC
Hi Vadislav,

It looks like there was a slight error in the XAML in the ResourceDictionary.

I changed:

> <OnPlatform.WinPhone>./Assets/Fonts/RopaSansTIDITPTT-Light-Fixed.otf#Ropa Sans TIDIT PTT Light</OnPlatform.WinPhone>

and 

> <OnPlatform.WinPhone>./Assets/Fonts/RopaSansTIDITPTT-Regular-Fixed.otf#Ropa Sans TIDIT PTT</OnPlatform.WinPhone>

to 

> <OnPlatform.WinPhone>\Assets\Fonts\RopaSansTIDITPTT-Light-Fixed.otf#Ropa Sans TIDIT PTT Light</OnPlatform.WinPhone>

and 

> <OnPlatform.WinPhone>\Assets\Fonts\RopaSansTIDITPTT-Regular-Fixed.otf#Ropa Sans TIDIT PTT</OnPlatform.WinPhone>

So using the Windfows backslash as the directory separator and removing the initial period, as per our docs on custom fonts:
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/fonts/#Using_a_Custom_Font
Comment 4 Vladislav Kosev 2015-05-01 18:56:50 UTC
F**k me! This was a case of RTFM it seems.

I apologize, I assumed that if this worked on a native WP app, it will work on Xamarin, but I was wrong. It seems that you do some font processing of your own.

A suggestion - it would be nice to add an explicit comment on this on the docs - I just read it diagonally and assumed I was supposed to pass a path valid for WP, not a special one and never paid attention to the code snippet itself. And when my path worked on WP 8 I assumed it would work on 8.1 also. It never occurred to me there was a gotcha there.

Thanks for the support!