-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unpackaged Win32 app using WinUI3 Xaml Island - problems with external fonts referenced in xaml #10054
Comments
Well, there are two things to note about this. Two examples of this:
It is therefore tough to believe that Microsoft.UI.Xaml.Application.LoadComponent has been updated to work with unpackaged applications, but no other WinUI 3 component wouldn't have been updated for unpackaged application support. But yes, this behaviour really should be documented. |
@DarranRowe Thank you for your response First, it is the component itself that determines if it supports a URI scheme. Second, WinUI 3 itself depends on ms-appx being interpreted as the current application's executable directory But yes, this behaviour really should be documented. All this is only part of the problem. What if I want to target a file outside the exe directory? Should I copy it there? That sounds completly wrong... |
I would be very surprised if support for unpackaged applications is dropped. This is especially true because of the scenarios that the Xaml Islands are meant to be used in and the Xaml Islands sample is set up to use the Xaml compiler.
This all depends. If your application is attempting to access a font outside of the .exe directory with the path hard coded in the Xaml, then you have bigger issues there. Remember, it is possible to run Windows setup and get it to set the system drive to something other than C. This would also force some other things which is problematic in an unpackaged application. |
I would be very surprised if support for unpackaged applications is dropped. If your application is attempting to access a font outside of the .exe directory with the path hard coded in the Xaml, then...
and the ttf font is in This is still one of the sticking points from the origins of WinUI 3, since UWP Xaml just wouldn't load a font from outside of the package. |
Describe the bug
<TextBlock Text="Test" FontFamily="file:///c:/font.ttf#font" />
does not work.It is probably a very old problem that no one tried to fix or find a workaround. It was reported almost five years ago...
WinUI3 Xaml does not support
file:
as part ofUri
. It can be seen inResourceManager::TryGetLocalResource
where onlyms-appdata:
,ms-appx:
andms-resource:
are handled.That is understandable for UWP applicarions and Packaged Desktop applications (although when they have
broadFileSystemAccess
it should work too, right?). But it should work for Unpackaged Deskop application.While searching for workaround I found that
ms-appdata:
cannot be used because it requires packaged application.ms-appx:
andms-resource:
can be used in unpackaged application to reach files in exe directory (and its subdirectories)ms-appx:///xxx
is essentialy transformed toms-resource:///files/xxx
.ms-resource:///files/xxx
usesm_pFallbackResourceProvider
and combinesxxx
withm_pBaseUri
.m_pBaseUri
is initialized toGetModuleFileName(NULL, applicationDirectory, MAX_PATH)
inCommonResourceProvider::Create
.This workaround looks like implementation detail and might stop working in future. And of course is limited to exe directory only. What else should we use?
Steps to reproduce the bug
<TextBlock Text="Test" FontFamily="file:///c:/font.ttf#font" />
does not work.Expected behavior
<TextBlock Text="Test" FontFamily="file:///c:/font.ttf#font" />
Should work.Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response
The text was updated successfully, but these errors were encountered: