0


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 !

karan chavan
  • 215
  • 2
  • 12
  • That will probably depend on your Linux environment, e.g. whether you have the genuine Arial font or a metrics-compatible replacement or a generic sans-serif replacement. It's easy to set this up with a VM if you want to test this yourself. – Rup Oct 03 '18 at 10:05
  • is there any way by which i can make linux font as same as my windows font, because I am getting rendering issues? thanks :) – karan chavan Oct 03 '18 at 10:08
  • If you're seeing rendering issues then you should edit your question to explain exactly what they are. Any code that relies on the pixel width of a string being the same across platforms sounds a bit fragile -- different display devices can have wildly varying resolutions. – G.M. Oct 03 '18 at 10:40
  • You may come close, but you will never get 100% compatible font rendering across GNU/Linux and Windows. Qt for GNU/Linux is built against Freetype and Qt for Windows is built against Microsoft's font engine. G.M. is right to suggest that you explaining exactly the issues you are having with it. They may be mitigable. – Cinder Biscuits Oct 03 '18 at 11:20
  • Sidenote: Even the same windows version can have different rendering, depending on ClearType settings... – king_nak Oct 03 '18 at 12:57
  • I have updated my question , kindly help , thanks :) – karan chavan Oct 04 '18 at 13:26

1 Answers1

0

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.

Artmetic
  • 350
  • 2
  • 12