0
votes

ITNOA

I have Xamarin forms project and I want to use ExtendedLabel for use own custom fonts in PCL project. when I follow ExtendedLabel instruction every things is ok for Droid project but when I want to run UWP project I see my fonts dose not apply for any label. the interesting note is when I use Xamarin built-in label and set FontFamily property with font name.ttf#friendly name pattern every things is ok for UWP project but ExtendedLabel does not show correct fonts in UWP app.

Dose anyone have idea to resolve UWP project problem?

I am using:

Visual Studio 2015 update 3
Xamarin forms 2.3.0.107
XLabs forms 2.2.0-pre5

thx

1

1 Answers

0
votes

Dose anyone have idea to resolve UWP project problem

Ref this document

For Android and iOS platform, we can use FontName property, but for Windows Phone platform, it uses FriendlyFontName property:

Quote:

This property is only necessary for the Windows Phone platform. This can be found on the first line of the font or in the font preview. If not given then the file name excluding the extension is used. However this cannot be guaranteed to work.

But seems like XLabs didn't handle the FriendlyFontName setting correctly. I just tried its official sample for UWP

For the ExtendedLabel scenario, the font setting is incorrect.

After some investigations, based on this issue, I found a workaround to fit Windows Phone and UWP scenario.

Setting FontName and using OnePlatform for WINRT scenario in xaml:

 <controls:ExtendedLabel FontName="Kristen ITC"
                                      FontSize="20"
                                      FriendlyFontName="Kristen ITC"
                                      HorizontalOptions="StartAndExpand"
                                      Text="This uses 'FontName' = 'Kristen ITC' set in XAML and 'OnPlatform' properties, size 20">
                <controls:ExtendedLabel.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                              iOS=""
                              Android=""
                              WinPhone="Kristen ITC"/>
                </controls:ExtendedLabel.FontFamily>              
</controls:ExtendedLabel>

Please notice that the specific Font should be installed in your platform OS.

Screenshot: enter image description here

Check my forked repository