How to get terminal size or font size in pixels?

python, terminal

Solution

Maybe. If your terminal software supports XTerm Control Sequences, then the sequence `\e[14t` will give you the size width*height in pixels.

Related:

- xtermctl - Put standard xterm/dtterm window control codes in shell parameters for easy use. Note that some terminals do not support all combinations.

Problem

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 in the terminal, in pixels? (I wrote equivalently because terminal width[px] = font width[px]*number of columns. or that is what I mean by terminal width.) I'm looking for a way that works with python 2 on linux, but I do appreciate answers that works only with python 3. Thanks!

Original source

Related problems