How to get terminal size or font size in pixels?

后端 未结 4 1870
执念已碎
执念已碎 2021-01-13 03:58

I\'ve seen some posts and answers about how to get the terminal size in numbers of columns and rows. Can I get the terminal size, or equivalently, the size of the font used

4条回答
  •  执念已碎
    2021-01-13 04:37

    The data structure that stores terminal info in linux is terminfo. This is the structure that any general terminal query would be reading from. It does not contain pixel information, since that is not relevant for the text-only terminals it was designed to specify.

    If you're running the code in an X compatible terminal, it is probably possible with control codes, but that would very likely not be portable.

提交回复
热议问题