-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Support reading fonts from files #14783
Conversation
var path = fontUri.AbsolutePath.TrimStart('/'); | ||
if (FileSystemUtils.TryGetAppPackageFileUri(path, out var uri)) | ||
fontUri = new Uri(uri, UriKind.RelativeOrAbsolute); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the real change for unpackaged, we determine the full path to the font and use that. Packaged still uses the same ms-appx://
. Technically the full path also works in packaged, but no need to change what works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use the bcl to get the full uri of a local path rather than write my own logic.
if (AppInfoUtils.IsPackagedApp) | ||
uri = $"ms-appx:///{filename.Replace('\\', '/')}"; | ||
else | ||
uri = $"file:///{path.Replace('\\', '/')}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be handled by the bcl in a much nicer way:
var uri = new Uri("c:\\foo");
var converted = uri.AbsoluteUri;
Example:
var r = new Uri ("C:\\foo\\bar") r.AbsoluteUri "file:///C:/foo/bar"
No need to worry about corner cases etc
Description of Change
This PR contains the maui changes to allow loading font files in unpackaged apps.
This will require a Win2D update after this issue is fixed: https://dev.azure.com/microsoft/OS/_workitems/edit/43890883
This can be merged today without the Win2D changes as the code for packaged is unchanged. Unpackaged will still fail to work, and magically start working with the new version.
Issues Fixed
Fixes #9104