Unsolved How to do font arithmetic with QFont in (non ingegral) pixels.
-
I am trying to get a true monospace font on Pi 400, which uses Qt 5.11.3.
QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont); if(f.styleHint() != QFont::TypeWriter) { f.setFamily("Monospace"); // Force Monospaced font f.setStyleHint(QFont::TypeWriter); }
The problem I have is that the conversion pixel <-> point requires rounding.
In an editor, if one tries to compute where is the n-th character or which character is under the n-th pixel, an integer conversion would be much easier.Is there such a thing as a Monospace font with integral (in pixel) size?
Or can I convert one? -
Answering my own question.
Bite the bullet and use QFontMetricsF and do some rounding where necessary.