Font Rendering difference in windows and Linux, Qt Cpp

934 Views Asked by At


I have,
QFontMetrics m_fm(QFont("Arial",14)); and
m_fm.width("Existing LAN IP Address from Project Network");
returns '297' (on windows)
can anyone tell me what it returns on linux compiler?
and if its different on linux then why so?
and how can we have same font rendering on windows as well as in linux.

Update:
I have a QTableView cell , in which I am writing data from multiple strings
collectively, I have to show data in 2 Lines in single row. (using .append("\n")).
Lets say column width is 140,
so I need data to fit in 140 pixels of the cell for one line
Therefore , i need to have data whose pixel width is less than 140, so that
it can be shown properly. in such case, depending on font(Arial)
I am computing
m_fm.width("Existing LAN IP Address from Project Network");
but it differs in Linux, as windows Arial font is not available. By any chance can I get proper pixel width ,
without installing Arial font in Linux system ?
Thanks in Advance !

1

There are 1 best solutions below

0
On

Try to load font on main.cpp QFontDatabase. Maybe You havent got the same font. Add font to resource file. Check DPI on screen or enable High antyaliasing on start app.