question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
  • .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:

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
walterlvcommented, May 8, 2021

Some users like to activate the hidden Administrator account which is very dangerous. These users may delete the fonts easily by accident without being aware of the consequence. I know that this behavior is extremely not recommended but our product has to support most of the computers and users all over the world. That’s why we bring up the issue here.

1reaction
miloushcommented, May 4, 2021

While I agree there are other ways to handle this, how likely is this an issue in practice?

Windows does not let users delete the font: image

Moreover, imagine you get an opportunity to handle this scenario. How do you handle it? With a fallback to different family? If so, you can already handle it be specifying your desired fallback when asking for a font family.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF Can't Find some Fonts
1 Answer 1 ... Check in your system's Windows folder. Do u have "Arial Rounded MT Bold" font installed on your system?? You...
Read more >
dotnet 读WPF 源代码笔记了解WPF 已知问题用户设备上不存在 ...
... 这个问题报告给官方,请看WPF known issues: Application will FailFast when not find the Arial font from system · Issue #4464 · dotnet/wpf ...
Read more >
"TypeInitializationException" or "FileFormatException" error ...
Symptoms. Windows Presentation Foundation (WPF) applications that request a fallback font or a character that is not included in the currently ...
Read more >
VS 2019 crash - Developer Community
Navigating to "C:\Windows\Fonts" confirmed that Arial was missing from the list of registered fonts. Going to the same folder in a command ...
Read more >
NET Framework 4.5 - Wine Application Database - WineHQ
Known Bugs ; 20220, Missing windowscodecs.dll.WICCreateImagingFactory_Proxy causes failure for many .NET 3.x/4.x (WPF) based installers/apps, CLOSED ; 26757 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found