-
Notifications
You must be signed in to change notification settings - Fork 694
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
feat: Font manifest #17118
base: master
Are you sure you want to change the base?
feat: Font manifest #17118
Conversation
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
6c9bdd0
to
06a53a3
Compare
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
06a53a3
to
80e37e3
Compare
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
Is that manifest a standard thing or something we're creating? |
@Youssef1313 This is a very unexpected addition. |
public FontStretch FontStretch | ||
{ | ||
get => (FontStretch)this.GetValue(FontStretchProperty); | ||
set => this.SetValue(FontStretchProperty, value); | ||
} | ||
|
||
public static DependencyProperty FontStretchProperty { get; } = | ||
DependencyProperty.Register( | ||
nameof(FontStretch), | ||
typeof(FontStretch), | ||
typeof(ContentPresenter), | ||
new FrameworkPropertyMetadata( | ||
FontStretch.Normal, | ||
FrameworkPropertyMetadataOptions.Inherits, | ||
(s, e) => ((ContentPresenter)s)?.OnFontStretchChanged((FontStretch)e.OldValue, (FontStretch)e.NewValue) | ||
) | ||
); |
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.
Let's use generated properties
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.
@jeromelaban For readability or perf?
My concern with generated DPs is that they cache the value when it changes. So, it's faster, but increases the object size. So my personal view to it is "speed vs memory"
public static DependencyProperty FontStretchProperty { get; } = | ||
DependencyProperty.Register( | ||
nameof(FontStretch), | ||
typeof(FontStretch), | ||
typeof(Control), | ||
new FrameworkPropertyMetadata( | ||
FontStretch.Normal, | ||
FrameworkPropertyMetadataOptions.Inherits, | ||
(s, e) => ((Control)s)?.OnFontStretchChanged((FontStretch)e.OldValue, (FontStretch)e.NewValue) | ||
) | ||
); |
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.
Generated properties
public static DependencyProperty FontStretchProperty { get; } = | ||
DependencyProperty.Register( | ||
nameof(FontStretch), | ||
typeof(FontStretch), | ||
typeof(TextBlock), | ||
new FrameworkPropertyMetadata( | ||
defaultValue: FontStretch.Normal, | ||
options: FrameworkPropertyMetadataOptions.Inherits, | ||
propertyChangedCallback: (s, e) => ((TextBlock)s).OnFontStretchChanged() | ||
) | ||
); |
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.
Generated properties
{ | ||
// While font family itself didn't change, OnFontFamilyChanged will invalidate whatever | ||
// needed for the rendering to happen correct on the next frame. | ||
_fontInfo.FontUpdated += OnFontFamilyChanged; |
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.
Same here.
public static DependencyProperty FontStretchProperty { get; } = | ||
DependencyProperty.Register( | ||
nameof(FontStretch), | ||
typeof(FontStretch), | ||
typeof(TextElement), | ||
new FrameworkPropertyMetadata( | ||
defaultValue: FontStretch.Normal, | ||
options: FrameworkPropertyMetadataOptions.Inherits, | ||
propertyChangedCallback: (s, e) => ((TextElement)s).OnFontStretchChanged() | ||
) | ||
); |
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.
Generated properties
src/Uno.UI/UI/Xaml/Documents/TextFormatting/FontDetailsCache.skia.cs
Outdated
Show resolved
Hide resolved
} | ||
catch | ||
{ | ||
// manifest file is not found or cannot be read. Ignore it. |
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.
We have an existing internal API to determine the presence of a file
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.
@jeromelaban What is it? I couldn't find it
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.
https://platform.uno/docs/articles/features/file-management.html#support-for-library-provided-assets: StorageFileHelper.ExistsInPackage
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.
@jeromelaban That's in Uno.UI.Toolkit 😕
src/Uno.UI/UI/Xaml/Documents/TextFormatting/FontDetailsCache.skia.cs
Outdated
Show resolved
Hide resolved
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
@carldebilly It's something we're creating/designing ourselves. |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17118/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17118/index.html |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17118/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17118/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17118/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
uri = new Uri(FontManifestHelpers.GetFamilyNameFromManifest(manifestStream, weight, style, stretch)); | ||
} | ||
} | ||
catch |
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.
Let's not hide the original error
} | ||
} | ||
|
||
var file = await StorageFile.GetFileFromApplicationUriAsync(uri); |
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.
Let's log in debug that we're fetching a font
|
||
// SKTypeface.FromFile may return null if the file is not found (SkiaSharp is not yet nullable attributed) | ||
skTypeFace = SKTypeface.FromFile(filePath); | ||
if (Uri.TryCreate(name, UriKind.Absolute, out var uri) && uri.Scheme == "ms-appx") |
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.
We have IsLocalResource
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17118/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
1 similar comment
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17118/index.html |
1201ae9
to
44390ad
Compare
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17118/index.html |
GitHub Issue (If applicable): closes #
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Run
results.Other information
Internal Issue (If applicable):