I am building my first UWP app (so still very newbie).
Detailed Context
I need any website (not just mine) to be able to open my app when the user clicks on a link and open my website when the app is not available. I can't use web-to-app-linking since it would not work on all browsers according to the documentation. So I need to use a custom scheme to open the app (I already have that feature).
Now I need to detect in JS if the app is installed to chose between the http link or the custom scheme link. The solution I found was to install a system-wide font with the application. A JS script can then compare the size of a caracter rendered with 'font-family: monospace;' with the size of the same caracter rendered with 'font-family: customAppFont, monospace;' and conclude about the app presence.
My problem
I don't know how to embed my ttf custom font file in my UWP app so that it is available to all browsers.
What I have tried so far
I have tried to use uap4:SharedFonts
App extension following this documentation. I uninstalled the app, built it again, and restarted my computer but my custom font is never made available to browsers (tested with Chrome and Edge).
My package.appxmanifest
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
IgnorableNamespaces="uap mp uap4">
...
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Applications>
<Application ...>
<Extensions>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="myprotocol" DesiredView="useMinimum">
<uap:DisplayName>MyApp</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
<uap4:Extension Category="windows.sharedFonts">
<uap4:SharedFonts>
<uap4:Font File="Assets\myCustomFont.ttf"/>
</uap4:SharedFonts>
</uap4:Extension>
</Extensions>
</Application>
</Applications>
</Package>
and I have added the file Assets\myCustomFont.ttf
to the solution with Visual Studio 2019.
What I would like to have
Make my custom font available in all browsers after the app has been installed. I also want the font to be automatically removed when the app is uninstalled.
Bonus : can I prevent the user from manually deleting the font ? (or better totally hide it from him ?)