I’m doing a small project for fun in C++ (in Ubuntu 11.04) and the program is text-based (all in the Gnome terminal). I’m using the ncurses library to change the font color, but I also want to print different sized text to the terminal, and can’t figure out how to do that with ncurses. Is there a way to do this (perhaps with ncurses, or with a different library)? Ideally, I’d want it to be terminal-independent,, but if it’s a solution that only works in Gnome, or only works in Ubuntu, or some other restriction like that then that’s better than nothing!
Thanks for your help as always.
I’ve tried the suggestion from Keith Thompson but couldn’t get it to work. Here’s my code:
cout << "\x1b]50;" << "10x20" << "\a" << flush;
cout << "test";
It just shows up as the same font size specified in the terminal preferences. I’m using: GNOME Terminal 2.32.1 if that helps!
At least for
xterm, you can change the current font by printing an escape sequence. The syntax isESCAPE ] 50 ; FONTNAME BEL.Here’s (an abbreviated version of) a script I use for this; I call it
xfont(the real one has more error checking):I don’t know which other terminal emulators recognize this sequence. In particular, I find that it doesn’t work under
screen, even if thescreensession is in anxtermwindow.Note that you have to specify the name of the font (
"10x20","9x15"), not its size.EDIT: I should pay more attention to tags. In C++, it would be something like:
UPDATE: With
xterm, this won’t work if you’re using TrueType fonts. Also, Dúthomhas suggests in a comment: