I am writing some text in a filter over a QVideoFrame in C++ and I would like that the font size automatically adapts to different screen sizes and pixel densities. I think this would be the implementation in C++ of the QML sp() function.
// Dots per inch
double dpi()
{
return QApplication::screens().count() > 0 ? QApplication::screens().first()->physicalDotsPerInch() : 160;
}
// sp function
double sp(double pixel)
{
return pixel * dpi() / 160;
}
Then, I just set a reference value for pixel size and call this function to set the font pixel size, as follows.
const double FONT_PIXEL_SIZE = 28;
QFont font;
font.setPixelSize(sp(FONT_PIXEL_SIZE));
However, if I do that I get a font size much bigger on Android than on iOS. What am I missing here?