[PR #2153] [MERGED] Fixes crash when specifying invalid font #24831

Open
opened 2026-01-31 09:05:36 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2153
Author: @miniksa
Created: 7/30/2019
Status: ✅ Merged
Merged: 7/30/2019
Merged by: @miniksa

Base: master ← Head: dev/miniksa/font-crash


📝 Commits (4)

  • 9edb5b8 Stop the crash with fonts by trying a few fallback/backup fonts if we can't find what was selected.
  • daaf0e9 Create fallback pattern for finding a font. Resolve and pass the locale name. Retrieve the font name while retrieving the font object. Use retrieved data in the _GetProposedFont methods instead of re-resolving it.
  • a6b46ca Code format
  • 853e825 Add details to schema about fallback. Finish comment explaining fallback pattern to doc comment on method.

📊 Changes

3 files changed (+177 additions, -30 deletions)

View changed files

📝 doc/cascadia/SettingsSchema.md (+1 -1)
📝 src/renderer/dx/DxRenderer.cpp (+160 -25)
📝 src/renderer/dx/DxRenderer.hpp (+16 -4)

📄 Description

Summary of the Pull Request

Adds fallback routine for when a font name is missing instead of crashing due to uncaught exception thrown when font cannot be found.

PR Checklist

Detailed Description of the Pull Request / Additional comments

For GDI and for DirectX using the stock Layouts and Formats, if your chosen font face name isn't found... something else is just picked on your behalf. When I wrote our custom DX code, I instead threw an exception when I couldn't find the chosen font face. That exception was uncaught and led to a crash.

I decided to just make the custom code act more like the stock code and attempt to choose a fallback if we cannot find what you've requested. I also improved a bit of the passing around of the chosen font name and added locale name information while I was at it.

Validation Steps Performed

  • Opened settings
  • Set font name to "arse"
  • Watched as nothing changed from previous Consolas selection
  • Closed application
  • Relaunched
  • Didn't crash this time, it just chose Consolas instead

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2153 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 7/30/2019 **Status:** ✅ Merged **Merged:** 7/30/2019 **Merged by:** [@miniksa](https://github.com/miniksa) **Base:** `master` ← **Head:** `dev/miniksa/font-crash` --- ### 📝 Commits (4) - [`9edb5b8`](https://github.com/microsoft/terminal/commit/9edb5b80afb4cf32105f810a4fbbcea22c53b598) Stop the crash with fonts by trying a few fallback/backup fonts if we can't find what was selected. - [`daaf0e9`](https://github.com/microsoft/terminal/commit/daaf0e953688aafd7c0d17fe3529591546ccd625) Create fallback pattern for finding a font. Resolve and pass the locale name. Retrieve the font name while retrieving the font object. Use retrieved data in the _GetProposedFont methods instead of re-resolving it. - [`a6b46ca`](https://github.com/microsoft/terminal/commit/a6b46ca9ea95024e6d3af85376d7d93f3dbaa41e) Code format - [`853e825`](https://github.com/microsoft/terminal/commit/853e82536f5c26d02123153ed35cc02366d8612f) Add details to schema about fallback. Finish comment explaining fallback pattern to doc comment on method. ### 📊 Changes **3 files changed** (+177 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `doc/cascadia/SettingsSchema.md` (+1 -1) 📝 `src/renderer/dx/DxRenderer.cpp` (+160 -25) 📝 `src/renderer/dx/DxRenderer.hpp` (+16 -4) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Adds fallback routine for when a font name is missing instead of crashing due to uncaught exception thrown when font cannot be found. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #550 * [x] I'm an employee * [x] Tests added/passed * [x] Doesn't need documentation * [x] I'm a core contributor <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments For GDI and for DirectX using the stock Layouts and Formats, if your chosen font face name isn't found... something else is just picked on your behalf. When I wrote our custom DX code, I instead threw an exception when I couldn't find the chosen font face. That exception was uncaught and led to a crash. I decided to just make the custom code act more like the stock code and attempt to choose a fallback if we cannot find what you've requested. I also improved a bit of the passing around of the chosen font name and added locale name information while I was at it. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - Opened settings - Set font name to "arse" - Watched as nothing changed from previous Consolas selection - Closed application - Relaunched - Didn't crash this time, it just chose Consolas instead --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:05:36 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24831