We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to use Metro Studio FontIcons in xamarin.forms project?

I went through your article here but unfortunately i dont get it working and your article is not clear

According to the article you are using PUA codee700 with&#x asGlyph? are you not supposed to generate it asGlyph instead of PUA? I tried like below but it didnt work.
I have registered the ttf file generated by Metro Studio as 

Assembly[assembly: ExportFont("FontIcons.ttf", Alias = "FontIcons")]

I am using XF 4.7 and ttf is embeddedresource

    <ContentPage.ToolbarItems>
        <ToolbarItem >
            <ToolbarItem.IconImageSource>
                <FontImageSource Glyph="&#xe700;"
                                 Color="Orange"
                                 FontFamily="FontIcons"
                                 Size="44" />
            </ToolbarItem.IconImageSource>
        </ToolbarItem>
    </ContentPage.ToolbarItems>

5 Replies 1 reply marked as answer

SP Sakthivel Palaniyappan Syncfusion Team July 3, 2020 10:56 AM UTC

Hi Emil,

Greetings from Syncfusion.

We have prepared the sample by generating FontIcon from the MetroStudio and providing it as an Embedded resource to check the reported issue. But we could not reproduce the issue from our side. Please check with the below sample and the TTF file generated.
 

Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/FontEmbeddedMetro-869090305

Video:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/20200428_171552.mp4-719352026.zip


Link: 
https://help.syncfusion.com/metro-studio/export-icon-font?_ga=2.176702309.1525778897.1593402149-764906472.1580379135

Please check with the above sample and if the issue still persists please modify the above sample with the TTF file generated from your side which will be helpful for us to analyze further to provide an appropriate solution at earliest. 

Regards,
Sakthivel P.
 



EM Emil July 3, 2020 11:00 PM UTC

OK so you have it in app xaml as 

 <ResourceDictionary>
            <OnPlatform x:Key="CustomFontFamily" x:TypeArguments="x:String">
                <On Platform="Android" Value="Sync FontIcons.ttf"/>
                <On Platform="iOS" Value="Sync FontIcons" />
            </OnPlatform>
        </ResourceDictionary>

I use other fonts without using as staticresource and referencing directly like. Does that not work for Metro App fonts? 
         FontFamily="FontIcons"


SP Sakthivel Palaniyappan Syncfusion Team July 6, 2020 09:11 AM UTC

Hi Emil,

Thanks for the update.

We have modified the sample by generating FontIcon from the MetroStudio and providing it as an Embedded resource with the FontFamily being set from the Alias Keyword and it is working fine at our end. Could you please check the below sample,


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/FontEmbeddedAlias-1992503119

If still the issue persists please modify the above sample with the TTF file generated from your side which will be helpful for us to analyze further to provide an appropriate solution at earliest. 

Regards,
Sakthivel P.
 



EM Emil July 6, 2020 09:31 AM UTC

Hi, 

thanks for the answer but I think that my problem was because i was trying in C# code. It works in xaml and not C# code. It looks like bug on xamarin. 
I created an issue on xamarin github https://github.com/xamarin/Xamarin.Forms/issues/11310



SP Sakthivel Palaniyappan Syncfusion Team July 7, 2020 09:52 AM UTC

Hi Emil,

Thanks for the update.

We have modified the sample with the Font provided in C#. Could you please check the below sample,

Code Snippet:

 
 var toolBarItem = new ToolbarItem 
            { 
                ClassId = "UnitDownloadClass", 
                Order = ToolbarItemOrder.Primary, 
                IconImageSource = new FontImageSource(){ 
                    Glyph = "\uE700", 
                    Color = Color.Yellow, 
                    FontFamily = "FontIcons", 
                    Size =   44 
                } 
            }; 
            ToolbarItems.Add(toolBarItem); 
  
Samplehttps://www.syncfusion.com/downloads/support/directtrac/general/ze/FontEmbeddedIcon-1519032510

Please check with the above and let us know if you have any concerns.

Regards,
Sakthivel P.
 


Marked as answer
Loader.
Up arrow icon