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

Open
opened 2026-01-30 21:54:21 +00:00 by claunia · 0 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:21 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#525