Skip to content
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

Typeface simulation fixes #17399

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

Gillibald
Copy link
Contributor

@Gillibald Gillibald commented Nov 1, 2024

What does the pull request do?

This PR ensures the system font collection tries to create a synthetic typeface if no match is found. This matches what the embedded font collection did in the past.

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0052941-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added the backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch label Nov 1, 2024
Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By reading the code I assume that this PR now applies font simulations to embedded fonts? Should we add some render test to ensure we don't regress this?

@@ -12,6 +12,7 @@ namespace Avalonia.Media.Fonts
public abstract class FontCollectionBase : IFontCollection
{
protected readonly ConcurrentDictionary<string, ConcurrentDictionary<FontCollectionKey, IGlyphTypeface?>> _glyphTypefaceCache = new();
protected IFontManagerImpl? _fontManager;
Copy link
Member

@MrJul MrJul Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should expose such a field publicly (same for _glyphTypefaceCache above, but that ship has sailed - it should probably be removed in v12).

Instead, TryCreateSynthethicGlyphTypeface() could be static and take an extra IFontManagerImpl parameter. Each of SystemFontCollection and EmbeddedFontCollection can keep their existing private field.

Copy link
Contributor Author

@Gillibald Gillibald Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Y you are right these members should be hidden behind some limited public API
The font collection feature should have been marked unstable because it needed frequent changes.

@MrJul MrJul added the bug label Nov 1, 2024
@@ -80,6 +81,47 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}

protected bool TryCreateSyntheticGlyphTypeface(IGlyphTypeface glyphTypeface, FontStyle style, FontWeight weight,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be private protected so it isn't part of the public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved that method to FontManger and made it internal

@Gillibald Gillibald force-pushed the typefaceSimulationTests branch from 43faf03 to a215d97 Compare November 1, 2024 10:45
@Gillibald
Copy link
Contributor Author

This should no longer have any public API changes

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0052947-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul enabled auto-merge November 3, 2024 11:53
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0052999-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053065-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added this pull request to the merge queue Nov 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 5, 2024
@Gillibald Gillibald added this pull request to the merge queue Nov 5, 2024
Merged via the queue into AvaloniaUI:master with commit 0785cf3 Nov 5, 2024
10 checks passed
@Gillibald Gillibald deleted the typefaceSimulationTests branch November 5, 2024 05:26
maxkatz6 pushed a commit that referenced this pull request Nov 14, 2024
@maxkatz6 maxkatz6 added backported-11.2.x and removed backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants