The SGR 22 (bold off) escape sequence doesn't work some of the time #528

Closed
opened 2026-01-30 21:54:24 +00:00 by claunia · 4 comments
Owner

Originally created by @j4james on GitHub (Jan 19, 2019).

  • Your Windows build number:

Microsoft Windows [Version 10.0.17763.195]

  • What you're doing and what's happening:

The SGR escape sequence \033[22m is supposed to disable the bold attribute, but sometimes it doesn't have any effect. It seems to depend on what other attributes have been enabled beforehand, and the order in which they've been applied.

For example, consider the sequence below, which enables the underline and bold attributes, then disables the bold attribute. This works as expected, leaving only the underline attribute enabled.

printf "\033[4;1mUNDERLINE & BOLD ON - \033[22mBOLD OFF\033[m\n"

image

However, if I change the order of the attributes, so the bold is applied before the underline, then the bold can no longer be disabled.

printf "\033[1;4mBOLD & UNDERLINE ON - \033[22mBOLD OFF?\033[m\n"

image

But that's not the only case that fails. If I attempt to turn off any of the other SGR attributes before attempting to turn off the bold, then that will also prevent the bold from being disabled.

printf "\033[1mBOLD ON - \033[24m\033[22mBOLD OFF?\033[m\n"

image

For comparison, this is what these test cases look like in XTerm:

image

  • What's wrong / what should be happening instead:

I would expect the SGR 22 escape sequence to disable the bold attribute regardless of what other attributes have been enabled/disabled, or the order in which they've been applied.

Originally created by @j4james on GitHub (Jan 19, 2019). * Your Windows build number: Microsoft Windows [Version 10.0.17763.195] * What you're doing and what's happening: The SGR escape sequence `\033[22m` is supposed to disable the bold attribute, but sometimes it doesn't have any effect. It seems to depend on what other attributes have been enabled beforehand, and the order in which they've been applied. For example, consider the sequence below, which enables the underline and bold attributes, then disables the bold attribute. This works as expected, leaving only the underline attribute enabled. printf "\033[4;1mUNDERLINE & BOLD ON - \033[22mBOLD OFF\033[m\n" ![image](https://user-images.githubusercontent.com/4181424/51431547-4db9d180-1c22-11e9-945d-9c279972df6d.png) However, if I change the order of the attributes, so the bold is applied before the underline, then the bold can no longer be disabled. printf "\033[1;4mBOLD & UNDERLINE ON - \033[22mBOLD OFF?\033[m\n" ![image](https://user-images.githubusercontent.com/4181424/51431555-675b1900-1c22-11e9-89c0-9981c170f18f.png) But that's not the only case that fails. If I attempt to turn off any of the other SGR attributes before attempting to turn off the bold, then that will also prevent the bold from being disabled. printf "\033[1mBOLD ON - \033[24m\033[22mBOLD OFF?\033[m\n" ![image](https://user-images.githubusercontent.com/4181424/51431561-8659ab00-1c22-11e9-8cb0-13018329c0fa.png) For comparison, this is what these test cases look like in XTerm: ![image](https://user-images.githubusercontent.com/4181424/51431569-9c676b80-1c22-11e9-8f8c-490203356ca7.png) * What's wrong / what should be happening instead: I would expect the SGR 22 escape sequence to disable the bold attribute regardless of what other attributes have been enabled/disabled, or the order in which they've been applied.
claunia added the Product-ConhostResolution-Fix-AvailableWork-ItemArea-VT labels 2026-01-30 21:54:24 +00:00
Author
Owner

@miniksa commented on GitHub (Jan 22, 2019):

@zadjii-msft, can you chime in on this one?

@miniksa commented on GitHub (Jan 22, 2019): @zadjii-msft, can you chime in on this one?
Author
Owner

@zadjii-msft commented on GitHub (Jan 22, 2019):

This may have actually gotten worse somehow in 19H1... It looks to me like the bolding stopped applying entirely.

I've filed MSFT:20266024 to take a look.

@zadjii-msft commented on GitHub (Jan 22, 2019): This may have actually gotten worse somehow in 19H1... It looks to me like the bolding stopped applying entirely. I've filed MSFT:20266024 to take a look.
Author
Owner

@zadjii-msft commented on GitHub (Jan 23, 2019):

Okay we definitely regressed something with how we handle bolding the "default" colored text - fix is out for PR now.
image

Thanks for the excellent (as always) bug report :)

@zadjii-msft commented on GitHub (Jan 23, 2019): Okay we definitely regressed something with how we handle bolding the "default" colored text - fix is out for PR now. ![image](https://user-images.githubusercontent.com/18356694/51574057-0e2cf880-1e61-11e9-9448-6f0ae7e1e57c.png) Thanks for the excellent (as always) bug report :)
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 15, 2019):

A fix for this went out in 18834, so I'm going to close it. We've filed a followup workitem to look at "default bold", which is a feature we missed in the new experimental terminal settings.

@DHowett-MSFT commented on GitHub (Feb 15, 2019): A fix for this went out in 18834, so I'm going to close it. We've filed a followup workitem to look at "default bold", which is a feature we missed in the new experimental terminal settings.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#528