Repository navigation
Support reading fonts from files - #14783
Merged
Merged
Conversation
mattleibow
marked this pull request as ready for review
April 26, 2023 15:08
mattleibow
commented
Apr 26, 2023
Comment on lines
+154
to
+156
| var path = fontUri.AbsolutePath.TrimStart('/'); | ||
| if (FileSystemUtils.TryGetAppPackageFileUri(path, out var uri)) | ||
| fontUri = new Uri(uri, UriKind.RelativeOrAbsolute); |
Member
Author
There was a problem hiding this comment.
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.
mattleibow
enabled auto-merge (squash)
April 26, 2023 19:09
mandel-macaque
approved these changes
Apr 26, 2023
mandel-macaque
left a comment
Contributor
There was a problem hiding this comment.
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('\\', '/')}"; |
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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