February 24, 2012

joonhwan joonhwan
Lab Rat
94 posts

[Solved] Qt text rendering issue on windows xp korean version

 

This is a quite old issue to me. please take a look following pictures

default style in windows xp korean

You can notice that the font used in menu bar and list widget looks different than others. (in korean windows xp, QApplication::font() returns “Gulim(굴림)” font by default).

now i changed style sheet like following

  1. QWidget { font-family: "Tahoma" }

and the window looks different now

after change font style as 'tahoma'

You see? now all pre-wierdly looked font is now rendered correctly.

For this kind of issue, in Korean Windows XP the glorious QtCreator that I’ve been wrestling with nowadays looks like…

ugly qtcreator

and

another ugly look

please compare it with any normal other windows application in my desktop

irfanview

I tried to use “-stylesheet” option when running QtCreator, but he never accepted this option. Any ideas?

EDITED

P.S Image itself looks as if it is rescaled in this post. In my real life it looks more ugly than it looks here…

 Signature 

joonhwan at gmail dot com

7 replies

February 24, 2012

Tobias Hunger Tobias Hunger
Robot Herder
3387 posts

You could try changing the font used by Qt apps using the qtconfig application (part of Qt itself). That should effect all Qt programs run by your user.

February 24, 2012

joonhwan joonhwan
Lab Rat
94 posts

Thanks, now I’m back to my place where no windows box exists unfortunately. I’ll try to do that next week. BTW, does qtconfig application exists in win32 platform? I thought it is only for X-window thing in unixy world

 Signature 

joonhwan at gmail dot com

February 24, 2012

Tobias Hunger Tobias Hunger
Robot Herder
3387 posts

Hmmm… I just checked, you are right, it does not seem to get build on windows. Sorry, I am not using windows regularly:-( I just assumed it would be there as well.

February 28, 2012

joonhwan joonhwan
Lab Rat
94 posts

Still nobody to know about this kind of issue?

 Signature 

joonhwan at gmail dot com

March 22, 2012

joonhwan joonhwan
Lab Rat
94 posts

I found that Qt (as of 4.8) doesn’t consider the cleartype setting in windows xp.
It could get current font smoothing type configuration from registry(HKCU\Control Panel\Desktop\FontSmoothingType) and then set every font’s style strategy in qt_set_windows_font_resources() which is located in qapplication_win.cpp

  1. static void qt_set_windows_font_resources()
  2. {
  3. #ifndef Q_WS_WINCE
  4.     NONCLIENTMETRICS ncm;
  5.     ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
  6.     SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0);
  7.  
  8.     QFont menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont, true);
  9.     QFont messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont, true);
  10.     QFont statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont, true);
  11.     QFont titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont, true);
  12.  
  13.     LOGFONT lfIconTitleFont;
  14.     SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
  15.     QFont iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont, true);
  16.  
  17.     QApplication::setFont(menuFont, "QMenu");
  18.     QApplication::setFont(menuFont, "QMenuBar");
  19.     QApplication::setFont(messageFont, "QMessageBox");
  20.     QApplication::setFont(statusFont, "QTipLabel");
  21.     QApplication::setFont(statusFont, "QStatusBar");
  22.     QApplication::setFont(titleFont, "Q3TitleBar");
  23.     QApplication::setFont(titleFont, "QWorkspaceTitleBar");
  24.     QApplication::setFont(iconTitleFont, "QAbstractItemView");
  25.     QApplication::setFont(iconTitleFont, "QDockWidgetTitle");

As it coule be realized, every function call to qt_LOGFONTtoQFont() could return a QFont object whose styleStrategy property correctly considering mentioned registry settings. For example,

  1. // ### maybe move to qapplication_win
  2. QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/)
  3. {
  4.     QString family = QString::fromWCharArray(lf.lfFaceName);
  5.     QFont qf(family);
  6.     qf.setItalic(lf.lfItalic);
  7.     if (lf.lfWeight != FW_DONTCARE)
  8.         qf.setWeight(weightFromInteger(lf.lfWeight));
  9.     int lfh = qAbs(lf.lfHeight);
  10.     qf.setPointSizeF(lfh * 72.0 / GetDeviceCaps(shared_dc(),LOGPIXELSY));
  11.     qf.setUnderline(false);
  12.     qf.setOverline(false);
  13.     qf.setStrikeOut(false);
  14.  
  15.     // ----- begin of mod
  16.     QSettings s("HKEY_CURRENT_USER\Control Panel\Desktop", QSettings::NativeFormat);
  17.     const int clearTypeEnum = 2;
  18.     if ( clearTypeEnum==s.value("FontSmoothingType",1) ) {
  19.        qf.setStyleStrategy(QFont::PreferAntialias);
  20.     }
  21.     // ---- end of mod
  22.     return qf;
  23. }

Now, I’m feeling like to report this, kinda officially, but don’t know how to.

I wish QtCreator itself could display its ui component more natuarally as well as other Qt application in my case.

 Signature 

joonhwan at gmail dot com

March 22, 2012

Tobias Hunger Tobias Hunger
Robot Herder
3387 posts

Please report this on http://bugreports.qt-project.org/ ! It will get lost here… :-(

March 22, 2012

joonhwan joonhwan
Lab Rat
94 posts

did my first bug report. here [bugreports.qt-project.org]
feels good no matter it could help or not. thanks.

 Signature 

joonhwan at gmail dot com

 
  ‹‹ How to plot a graph in Qt without using QWT      QGLWidget::renderText => incomplete text ››

You must log in to post a reply. Not a member yet? Register here!