Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: Binder News on October 25, 2011, 09:13:45 pm

Title: Controlling terminal fonts
Post by: Binder News on October 25, 2011, 09:13:45 pm
Hey all! After a long time of no activity here, I am finally back, with a question.
How can I, FROM INSIDE A C/C++ PROGRAM, change the font of the terminal (this is on Linux)?

Thanks,
Binder News
Title: Re: Controlling terminal fonts
Post by: BalancedFury on October 25, 2011, 09:16:13 pm
Right click on the white bar inside a black screen, and click properties.
I hope this helps
Title: Re: Controlling terminal fonts
Post by: alberthrocks on October 25, 2011, 09:26:34 pm
No, this is not possible. You can change the color, change lines, etc. but NOT the font. (If there's such a thing, it's dependent on a specific terminal emulator.)

However, if you're talking about printing underline/bold/(italics??) text, then yes it is possible! :)
For bold, you would do this:
Code: [Select]
printf("\033[1mBold text is awesome!\033[0m");Those are escapes for the ANSI standard terminal formatting. Take a peek here for more options:
http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html

EDIT: You can also see the results live without compiling any C/C++!
Simply type this into your terminal:
Code: [Select]
echo -e "\033[1mBold text is awesome"'!'"\033[0m" # The -e enables escapes
# OR... yes, it IS printf you're seeing below!
printf "\033[0mBold text is awesome"'!'"\033[0m" # I'm not too sure if the shell's printf supports printf(); formatting, aka printf("number %i", var); check your local man pages for details.
Title: Re: Controlling terminal fonts
Post by: Binder News on October 25, 2011, 09:39:38 pm
Okay. Thanks. I wanted to port Block Dude to the terminal, and wanted to use my own font, but I guess I'll have to use the default character set. Thanks.