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

Introdcue font collections #10455

Merged
merged 15 commits into from
Mar 4, 2023

Conversation

Gillibald
Copy link
Contributor

@Gillibald Gillibald commented Feb 24, 2023

What does the pull request do?

This PR introduces font collection to be able to manage the lifetime of created glyph typefaces and to be able to load fonts from custom sources. As long as it is possible to obtain a stream of the font file it can be loaded.

Fonts within font collections are referenced via FontFamily="fonts:CollectionName#FamilyName"

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

@Gillibald Gillibald changed the title Introdcue font collections [WIP] Introdcue font collections Feb 24, 2023
@Gillibald Gillibald force-pushed the feature/fontCollections branch from 62e5ab1 to 67e6ba4 Compare February 28, 2023 08:27
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0031071-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@Gillibald Gillibald changed the title [WIP] Introdcue font collections Introdcue font collections Mar 2, 2023
@maxkatz6 maxkatz6 enabled auto-merge March 3, 2023 13:39
@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 3, 2023
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0031294-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2023
@danwalmsley danwalmsley enabled auto-merge March 3, 2023 21:53
@danwalmsley danwalmsley added this pull request to the merge queue Mar 3, 2023
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0031330-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2023
@danwalmsley danwalmsley added this pull request to the merge queue Mar 3, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2023
@danwalmsley danwalmsley added this pull request to the merge queue Mar 4, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2023
@danwalmsley danwalmsley added this pull request to the merge queue Mar 4, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2023
@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 4, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2023
@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 4, 2023
@maxkatz6
Copy link
Member

maxkatz6 commented Mar 4, 2023

@Gillibald tests are randomly failing because of this PR:

02:11:33 [ERR] [xUnit.net 00:00:06.11]     Avalonia.Controls.UnitTests.TimePickerTests.SelectedTimeChanged_Should_Fire_When_SelectedTime_Set [FAIL]
02:11:33 [DBG]   Failed Avalonia.Controls.UnitTests.TimePickerTests.SelectedTimeChanged_Should_Fire_When_SelectedTime_Set [1 ms]
02:11:33 [DBG]   Error Message:
02:11:33 [DBG]    System.InvalidOperationException : Unable to locate 'Avalonia.Platform.IAssetLoader'.
02:11:33 [DBG]   Stack Trace:
02:11:33 [DBG]      at Avalonia.LocatorExtensions.GetRequiredService[T](IAvaloniaDependencyResolver resolver) in /_/src/Avalonia.Base/AvaloniaLocator.cs:line 136
02:11:33 [DBG]    at Avalonia.Media.Fonts.EmbeddedFontCollection.Initialize(IFontManagerImpl fontManager) in /_/src/Avalonia.Base/Media/Fonts/EmbeddedFontCollection.cs:line 36
02:11:33 [DBG]    at Avalonia.Media.FontManager.TryGetGlyphTypeface(Typeface typeface, IGlyphTypeface& glyphTypeface) in /_/src/Avalonia.Base/Media/FontManager.cs:line 112
02:11:33 [DBG]    at Avalonia.Media.Typeface.get_GlyphTypeface() in /_/src/Avalonia.Base/Media/Typeface.cs:line 87
0

Seems like IAssetLoader needs to be registered in the scope of each of these tests. It passes probably only if loader was registered by some another test (which is also a problem, as all locator registrations in tests should be done in locator scope and cleared after the test).

@maxkatz6
Copy link
Member

maxkatz6 commented Mar 4, 2023

Or a mock of asset loader should be registered.

Merged via the queue into AvaloniaUI:master with commit 9855dc7 Mar 4, 2023
@danwalmsley
Copy link
Member

Locally on mac and windows that unit test doesnt not cause any jobs to be posted to the dispatcher.

Only randomly sometimes on CI does it happen.

2023-03-03T12:09:36.8964822Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Controls.TextBlock.MeasureOverride(Size availableSize) in /_/src/Avalonia.Controls/TextBlock.cs:line 707�[0m
2023-03-03T12:09:36.8966875Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in /_/src/Avalonia.Base/Layout/Layoutable.cs:line 532�[0m
2023-03-03T12:09:36.8968840Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in /_/src/Avalonia.Base/Layout/Layoutable.cs:line 364�[0m
2023-03-03T12:09:36.8971073Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.LayoutHelper.MeasureChild(Layoutable control, Size availableSize, Thickness padding, Thickness borderThickness) in /_/src/Avalonia.Base/Layout/LayoutHelper.cs:line 47�[0m
2023-03-03T12:09:36.8974848Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size availableSize) in /_/src/Avalonia.Controls/Presenters/ContentPresenter.cs:line 591�[0m
2023-03-03T12:09:36.8977443Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in /_/src/Avalonia.Base/Layout/Layoutable.cs:line 532�[0m
2023-03-03T12:09:36.8979590Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in /_/src/Avalonia.Base/Layout/Layoutable.cs:line 364�[0m
2023-03-03T12:09:36.8981543Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.LayoutManager.Measure(Layoutable control) in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 294�[0m
2023-03-03T12:09:36.8983558Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.LayoutManager.Measure(Layoutable control) in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 280�[0m
2023-03-03T12:09:36.8985534Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.LayoutManager.ExecuteMeasurePass() in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 254�[0m
2023-03-03T12:09:36.8987558Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.LayoutManager.InnerLayoutPass() in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 236�[0m
2023-03-03T12:09:36.8989548Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.LayoutManager.ExecuteLayoutPass() in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 148�[0m
2023-03-03T12:09:36.8991527Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Layout.LayoutManager.ExecuteQueuedLayoutPass() in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 108�[0m
2023-03-03T12:09:36.8993508Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run() in /_/src/Avalonia.Base/Threading/JobRunner.cs:line 193�[0m
2023-03-03T12:09:36.8995535Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in /_/src/Avalonia.Base/Threading/JobRunner.cs:line 38�[0m
2023-03-03T12:09:36.8997314Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Threading.Dispatcher.RunJobs() in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 69�[0m
2023-03-03T12:09:36.8999498Z �[90m12:09:36�[0m�[90m [�[0m�[97;1mDBG�[0m�[90m] �[0m   at Avalonia.Controls.UnitTests.TimePickerTests.SelectedTimeChanged_Should_Fire_When_SelectedTime_Set() in D:\a\1\s\tests\Avalonia.Controls.UnitTests\TimePickerTests.cs:line 28�[0m

so this code path never happens.

What would make that code path execute?

using (UnitTestApplication.Start(Services))
            {
                bool handled = false;
                TimePicker timePicker = new TimePicker();
                timePicker.SelectedTimeChanged += (s, e) =>
                {
                    handled = true;
                };
                TimeSpan value = TimeSpan.FromHours(10);
                timePicker.SelectedTime = value;
                Threading.Dispatcher.UIThread.RunJobs();
                Assert.True(handled);
            }
            ```
            

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants