dotnet / dotnet/wpf

WPF known issues: Application will FailFast when not find the Arial font from system

Open
#4,464 7 comments 1 reaction 0 assignees View on GitHub
.NET Framework
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: All
* Windows version: All
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

**Problem description:**

When we indirectly or directly call the FirstFontFamily method of FontFamily.cs, if we call FindFirstFontFamilyAndFace and the font is not found, then we will look for the system's Arial font.

https://github.com/dotnet/wpf/blob/6cd4ee063a4d1f764a8e5f27f02df971dbc4a900/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FontFamily.cs#L350-L362

The LookupFontFamily method return NULL when the user deletes the Arial font. And then we will enter the `Invariant.Assert(family != null)` to make the Application to FailFast.

https://github.com/dotnet/wpf/blob/6cd4ee063a4d1f764a8e5f27f02df971dbc4a900/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FontFamily.cs#L361

https://github.com/dotnet/wpf/blob/6cd4ee063a4d1f764a8e5f27f02df971dbc4a900/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Invariant.cs#L85-L91

https://github.com/dotnet/wpf/blob/6cd4ee063a4d1f764a8e5f27f02df971dbc4a900/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Invariant.cs#L199-L213

I don't think this is a good design.

**Actual behavior:**

Application will FailFast and I can not do anything and do not know why


**Expected behavior:**

We can handle it or receive the event

**Minimal repro:**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.