Pxaml
Pxaml

Reputation: 553

Fontawsome PRO 6 Xamarin Forms

I have been trying to add these fonts into my xamarin project , but I don't know what Iam doing wrong. All I get is a question ( ? )icon . These are my steps

Edits

  1. Added a new folder named fonts and copied the font inside my forms project See below

enter image description here

  1. Assembly.cs on ios project

enter image description here

Also , again inside the resources just in case enter image description here

Now, on xaml enter image description here

Results enter image description here

  1. Download to the font awesome pro 6

  2. List item

  3. Add the fonts to my Xam Project ios and android enter image description here

enter image description here

Upvotes: 1

Views: 389

Answers (1)

Amjad S.
Amjad S.

Reputation: 1241

Add ExportFont attribute in your shared project.The most obvious place would be inside your App.xaml.cs or AssemblyInfo.cs. However, since the attribute will register this on assembly level, you can put this anywhere. The placement of the attribute depends on how visible you want to make it to other/future developers.

Anywhere outside a namespace will work. Just add this, you don’t need to include the subfolders:

 [assembly: ExportFont("Samantha.ttf")]

assemblyinfo.cs like this:

[assembly: ExportFont("Samantha.ttf", Alias = "Samantha")]
[assembly: ExportFont("Pacifico.ttf", Alias = "Pacifico")]
[assembly: ExportFont("HugMe.ttf", Alias = "HugMe")]

Usage:

<Label FontFamily="Samantha" />

Note: Add the font file (otf or ttf) to your shared project and mark it as embedded resource

Like this

Upvotes: 1

Related Questions