Change Terminal Font Size with C++

a 夏天 提交于 2019-12-05 05:42:39

At least for xterm, you can change the current font by printing an escape sequence. The syntax is ESCAPE ] 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):

#!/usr/bin/perl

use strict;
use warnings;

print "\e]50;@ARGV\a";

I don't know which other terminal emulators recognize this sequence. In particular, I find that it doesn't work under screen, even if the screen session is in an xterm window.

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:

std::cout << "\x1b]50;" << font_name << "\a" << std::flush;

The best you can do is to use bold font. Terminal emulates real text-based terminal so it doesn't support different fonts at once.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!