Reputation: 553
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
Also , again inside the resources just in case
Upvotes: 1
Views: 389
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
Upvotes: 1