0

Hello to all I created a Xamarin forms project and a series of user interfaces in it. I also copied some fonts in the asset folder of the Android project, which I used in user interfaces. It does not recognize fonts when I pack this project and refer to another project. I realized that I need to make changes to the * .cspro file of the project, but I do not know what to do. Thanks for your help

project properties:

enter image description here

NajiMakhoul
  • 1,623
  • 2
  • 16
  • 30
  • Hi, why not using the custom font directly in the another project? https://devblogs.microsoft.com/xamarin/embedded-fonts-xamarin-forms/ – Junior Jiang Nov 25 '20 at 07:27
  • Hi, Because I want to create a package ready to be published in nuget and I do not want the end user to need to install the font – حسین مه آبادی Nov 25 '20 at 07:58
  • Okey, you mean want to develop a nuget package for for other project to install custom fonts? – Junior Jiang Nov 25 '20 at 08:49
  • Okey, A similar question on SO that you could have a look : https://stackoverflow.com/questions/54091668/how-do-i-distribute-a-font-in-a-nuget-package-using-the-new-csproj-approach-to-c Also here is a github repo for a nuget package that uses fonts for icons, but this should work for any font, so you could refer to this repo for an example of how to do it: https://github.com/jsmarcus/Iconize – Junior Jiang Nov 26 '20 at 02:10

1 Answers1

0

I found this code but it does not work for android

  <ItemGroup>
    <Folder Include ="fonts" Pack="true"/>
    <FontFiles Include="fonts/*.ttf" Pack="true"/>
  </ItemGroup>
  
  <ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
    <Folder Include="Assets\" />
    <AndroidAsset Include="@(FontFiles)" Link="Assets\%(Filename)%(Extension)" />
  </ItemGroup>