Skip to content

Commit

Permalink
Fix #9393, impossible to select 'regular' font style for labels
Browse files Browse the repository at this point in the history
- While ostensibly fixes the issue, there is still a flaw with QFontDatabase.styleString() returning generic style names
  • Loading branch information
dakcarto committed Feb 22, 2014
1 parent d12e08e commit 90aa18a
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/core/qgsfontutils.cpp
Expand Up @@ -110,16 +110,7 @@ bool QgsFontUtils::updateFontViaStyle( QFont& f, const QString& fontstyle, bool
if ( !fallback )
{
// does the font even have the requested style?
bool hasstyle = false;
foreach ( const QString &style, fontDB.styles( f.family() ) )
{
if ( style == fontstyle )
{
hasstyle = true;
break;
}
}

bool hasstyle = fontFamilyHasStyle( f.family(), fontstyle );
if ( !hasstyle )
{
return false;
Expand All @@ -129,16 +120,18 @@ bool QgsFontUtils::updateFontViaStyle( QFont& f, const QString& fontstyle, bool
// is the font's style already the same as requested?
if ( fontstyle == fontDB.styleString( f ) )
{
return true;
return false;
}

int defaultSize = QApplication::font().pointSize(); // QFontDatabase::font() needs an integer for size
QFont appfont = QApplication::font();
int defaultSize = appfont.pointSize(); // QFontDatabase::font() needs an integer for size

QFont styledfont;
bool foundmatch = false;

// if fontDB.font() fails, it returns the default app font; but, that may be the target style
styledfont = fontDB.font( f.family(), fontstyle, defaultSize );
if ( QApplication::font() != styledfont )
if ( appfont != styledfont || fontstyle != fontDB.styleString( f ) )
{
foundmatch = true;
}
Expand Down

0 comments on commit 90aa18a

Please sign in to comment.