Skip to content

Fix crash when launcher UI fonts are installed system-wide#1337

Open
andy013 wants to merge 1 commit intoAlbeoris:mainfrom
andy013:launcher_crash_fix
Open

Fix crash when launcher UI fonts are installed system-wide#1337
andy013 wants to merge 1 commit intoAlbeoris:mainfrom
andy013:launcher_crash_fix

Conversation

@andy013
Copy link
Copy Markdown
Contributor

@andy013 andy013 commented Jan 4, 2026

Issue: #1327

If a user has any of the fonts that are shipped with the launcher installed, it will crash from the second time it is ran onwards.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FontFamily x:Key="CenturyGothic">pack://application:,,,/Fonts/#Century Gothic</FontFamily>
<FontFamily x:Key="CenturyGothic-Bold">pack://application:,,,/Fonts/centurygothic-bold.ttf</FontFamily>
<FontFamily x:Key="NotoEmoji">pack://application:,,,/Fonts/#Noto Emoji Regular</FontFamily>
<FontFamily x:Key="Overpass">pack://application:,,,/Fonts/#Overpass</FontFamily>
</ResourceDictionary>

If you are trying to recreate this issue, you don't need to install these fonts. You can manually add the name of any of the above fonts to the FontList file.

The first time the launcher is ran the FontList file of installed fonts doesn't exist and so the crash doesn't happen.

If a user has one of the fonts installed, the next time it is ran this code at line 517 will cause the crash:

foreach (String value in options)
{
if (Lang.Res.Contains(value))
choices.Add((String)Lang.Res[value]);
else
choices.Add(value);
}

The above code looks to see if there is a specific language string for the combo box values. The crash happens because Lang.Res contains the FontFamily objects of the above 4 fonts. It returns a match and then crashes when cast to a string.

The same problem exists in RefereshComboBoxes although it currently crashes before that can ever throw an error.

I'm not sure what the best way to fix this is but this is my attempt. I created a separate ResourceDictionary just for all the language strings. This way, whenever you lookup a key in Lang.Res you can guarantee it's a string from one of the language files and not another type of resource.

@WarpedEdge
Copy link
Copy Markdown
Contributor

Hey Andy, have only recently been seeing you around here. Welcome to the community! Great to see another contributor.

@andy013
Copy link
Copy Markdown
Contributor Author

andy013 commented Jan 5, 2026

@WarpedEdge Thanks! You probably won't see much of me as I'm quite busy with other projects, but I try and help if I can.

@andy013
Copy link
Copy Markdown
Contributor Author

andy013 commented Jan 5, 2026

It might be better to disable looking for translation strings for font names. With this PR you could still run into an issue where a font has the same name as one of the translation keys and gets translated when it shouldn't be. Font names should never be translated.

Feel free to close this PR if you have a better solution to this. Hopefully it still helped to identify the cause of the crash.

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.

2 participants