Forum Cross Platform with Xamarin

How to include FontAwesome to UWP Apps without a separate installation of the font?

Hi there,
I'm using FontAwesome in a cross-platform app and it works perfectly on my own computer and on every Android device (haven't tried iOS yet), but when I try to publish and install my UWP app on another windows device, where FontAwesome is not installed separately, all the icons do not show.

Is there a way to include the used icons in the app? As I use FontAwesome Pro, I may not spread the files to install FontAwesome Pro.

Thanks,
Tanja!

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Did you set the Copy to Output Directory “Copy always” on UWP?
    Could you find the corresponding font files in your packages after packing?

    where FontAwesome is not installed separately

    If the file has located in your project it could be consumed by your application. There's no need to install the custom font on your Windows devices.

  • tanja_vtanja_v Member ✭✭

    Hi,
    thanks for your fast response!
    Settings are on Content - Copy always.

    Could you tell me where I might find the corresponding files?

  • LandLuLandLu Member, Xamarin Team Xamurai

    Try to create a test label to display your installation folder path.
    Firstly, use dependency service to retrieve the path like:

    [assembly: Dependency(typeof(FileManager))]
    namespace Sample.uwp
    {
        public class FileManager : IFilePathManager
        {
            public string GetInstallationPath()
            {
                Windows.Storage.StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
                return installedLocation.Path;
            }
        }
    }
    

    We could display this path on Forms like:

    myLable.Text = DependencyService.Get<IFilePathManager>().GetInstallationPath();
    

    Finally, we could reach the folder through this path.

  • tanja_vtanja_v Member ✭✭

    Awesome, thanks so far.
    Im trying debugging mode now, all .otf-Files are available in the assets-directory of the installation path. But still, icons do not show unless I install the font separately.

  • LandLuLandLu Member, Xamarin Team Xamurai

    Have you tried other custom fonts?
    I test with a custom font which is not installed on my Windows.
    This is the font:

    Here is the font gallery of my device:

    And here is the effect:

    This application is packaged by another device. I installed it on this testing device.

  • tanja_vtanja_v Member ✭✭

    I just tried another custom font, and it only works when using the .ttf-file, but not with the .otf-file.

  • LandLuLandLu Member, Xamarin Team Xamurai
    You could see my font is an otf file from my screenshot above.
  • tanja_vtanja_v Member ✭✭

    Yeah I saw. Maybe this is dependent on a Visual Studio setting ?

  • LandLuLandLu Member, Xamarin Team Xamurai

    I haven't changed any settings on my side.

Sign In or Register to comment.