Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.1
-
None
Description
I have some text drawn using a QFont where I setLetterSpacing() and want to get the width of the rendered text, but the letter spacing does not seem to affect the computed width, but does affect the rendered text.
I have an example snippet below which I compiled against Qt 5.15.1. I would expect the computed width for the two fonts to be different, but both return 51 for me.
#include <QApplication> #include <QFont> #include <QFontMetrics> #include <iostream> int main(int argc, char *argv[]) { QApplication a(argc, argv); const QString text = "Example"; QFont font; QFontMetrics fontMetrics( font ); QFont spacedFont; spacedFont.setLetterSpacing( QFont::AbsoluteSpacing, 20 ); QFontMetrics spacedFontMetrics( spacedFont ); std::cerr << "Default font width = " << fontMetrics.boundingRect( text ).width() << std::endl; std::cerr << "Spaced font width = " << spacedFontMetrics.boundingRect( text ).width() << std::endl; return 0; }