Skip to content
Sign upLog in

How do you change the font in Python?

Profile icon
gibbsfreenergy

How do you change the font in Python? Would be pretty cool to learn this.

You are viewing a single comment. View All
Answered by adl212 [earned 5 cycles]
View Answer
Profile icon
adl212

Unfortunately, you can not change the font family of text in python. But, you can change the color of the text or add markdown to the text. Hope this answers your question! Upvote or choose as the correct answer if so.

Profile icon
adl212

@JosephSanthosh
The ANSI color codes are

BLACK = "\033[0;30m" RED = "\033[0;31m" GREEN = "\033[0;32m" BROWN = "\033[0;33m" BLUE = "\033[0;34m" PURPLE = "\033[0;35m" CYAN = "\033[0;36m" LIGHT_GRAY = "\033[0;37m" DARK_GRAY = "\033[1;30m" LIGHT_RED = "\033[1;31m" LIGHT_GREEN = "\033[1;32m" YELLOW = "\033[1;33m" LIGHT_BLUE = "\033[1;34m" LIGHT_PURPLE = "\033[1;35m" LIGHT_CYAN = "\033[1;36m" LIGHT_WHITE = "\033[1;37m" BOLD = "\033[1m" FAINT = "\033[2m" ITALIC = "\033[3m" UNDERLINE = "\033[4m" BLINK = "\033[5m" NEGATIVE = "\033[7m" CROSSED = "\033[9m" END = "\033[0m"

Just add them to your print function and it will change the text!

Profile icon
gibbsfreenergy

@adl212
thx, but is there any other way I can decorate the text even more besides colors?

Profile icon
adl212

@JosephSanthosh
You can use bold, underline, and etc.

Profile icon
gibbsfreenergy

do u know what or where the codes are?

@adl212

Profile icon
gibbsfreenergy

how do i write it inside a print() [email protected]

Profile icon
adl212

@JosephSanthosh
You would do something like print("\033[1m" + "This is bold text!" + "\033[0m")Hope this helps!

Profile icon
gibbsfreenergy

never mind I found out. [email protected]

Profile icon
Coder100

there's more...

@adl212

Profile icon
adl212

@Coder100
Ok, go ahead and tell us!

Profile icon
Coder100

alright, there's also rgb support:

\033[38;2;⟨r⟩;⟨g⟩;⟨b⟩m

and 8bit (256 colors):

\033[38;5;⟨n⟩m

@adl212

Profile icon
gibbsfreenergy

there are 256 [email protected]

Profile icon
adl212

@Coder100
Ok, great! I didn't know of these!

Profile icon
Coder100

:) glad to introduce ya

@adl212

Profile icon
gibbsfreenergy

thanks guys

@Coder100
@adl212

Profile icon
Coder100

np :)

@JosephSanthosh

Profile icon
adl212

@JosephSanthosh
No problem!