Reputation: 3535
I have been working on a program that prints bold text in the terminal in some cases, but I have been wondering, why are certain characters like *, #, and ~ not printed in bold? Also, is there anyway to get them to be printed in bold. I already know how to use escape sequences to do that, but is there some other way? Here is a code example:
#This isn't bold:
print "\033[94m####\033[1m"
#But this is:
print "\033[94mHello\033[1m"
Edit: I'm dumb. The above code should be this instead:
print "\033[94;1m####\033[0m"
Upvotes: 0
Views: 105
Reputation: 168866
You are printing the bold SGR command after the text. You must print the bold command before the text for it to have an effect:
bold='\033[1m'
blue='\033[94m'
normal='\033[m'
print bold+'Hello'+normal # This prints in bold
print bold+'###'+normal # So does this
Reference:
Upvotes: 1