Skip to content

Commit

Permalink
Try to use integer font metrics when the Qt runtime version is recent…
Browse files Browse the repository at this point in the history
… enough
  • Loading branch information
realnc committed Mar 29, 2012
1 parent c0ce534 commit 05bc9c9
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions src/sysframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,34 @@ CHtmlSysFrameQt::main( QString gameFileName )
}


#if QT_VERSION < 0x040700
static int
qtRuntimeVersion()
{
const QList<QByteArray> verList(QByteArray(qVersion()).split('.'));
if (verList.size() < 3) {
// Something isn't right. The Qt version string should have
// at least three fields.
return 0;
}
bool ok;
int major = verList.at(0).toInt(&ok);
if (not ok) {
return 0;
}
int minor = verList.at(1).toInt(&ok);
if (not ok) {
return 0;
}
int patch = verList.at(2).toInt(&ok);
if (not ok) {
return 0;
}
return QT_VERSION_CHECK(major, minor, patch);
}
#endif


CHtmlSysFontQt*
CHtmlSysFrameQt::createFont( const CHtmlFontDesc* font_desc )
{
Expand All @@ -375,12 +403,22 @@ CHtmlSysFrameQt::createFont( const CHtmlFontDesc* font_desc )

CHtmlFontDesc newFontDesc = *font_desc;
CHtmlSysFontQt newFont;
newFont.setStyleStrategy(QFont::StyleStrategy(QFont::PreferOutline
| QFont::PreferQuality
QFont::StyleStrategy strat;
#if QT_VERSION >= 0x040700
| QFont::ForceIntegerMetrics
// We're building with a recent enough Qt; use ForceIntegerMetrics directly.
strat = QFont::StyleStrategy(QFont::PreferOutline | QFont::PreferQuality
| QFont::ForceIntegerMetrics);
#else
// We're building with a Qt version that does not offer ForceIntegerMetrics.
// If we're running on a recent enough Qt, use the ForceIntegerMetrics enum
// value directly.
if (qtRuntimeVersion() >= 0x040700) {
strat = QFont::StyleStrategy(QFont::PreferOutline | QFont::PreferQuality | 0x0400);
} else {
strat = QFont::StyleStrategy(QFont::PreferOutline | QFont::PreferQuality);
}
#endif
));
newFont.setStyleStrategy(strat);

// Use the weight they provided (we may change this if a weight modifier is
// specified).
Expand Down

0 comments on commit 05bc9c9

Please sign in to comment.