[PR #2153] Fixes crash when specifying invalid font #24836

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

Original Pull Request: https://github.com/microsoft/terminal/pull/2153

State: closed
Merged: Yes


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
**Original Pull Request:** https://github.com/microsoft/terminal/pull/2153 **State:** closed **Merged:** Yes --- <!-- 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
claunia added the pull-request label 2026-01-31 09:05:37 +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#24836