Navigation Menu

Skip to content

Commit

Permalink
[labeling] When changing font families, reset to correct regular/book
Browse files Browse the repository at this point in the history
style if current style is not available

Previously the font would be reset to the first style alphabetically,
usually 'Bold'. Now it correctly resets to the standard font style.
  • Loading branch information
nyalldawson committed Jan 23, 2017
1 parent c1658fb commit 012515c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/gui/qgstextformatwidget.cpp
Expand Up @@ -983,13 +983,21 @@ void QgsTextFormatWidget::populateFontCapitalsComboBox()
void QgsTextFormatWidget::populateFontStyleComboBox()
{
mFontStyleComboBox->clear();
Q_FOREACH ( const QString &style, mFontDB.styles( mRefFont.family() ) )
QStringList styles = mFontDB.styles( mRefFont.family() );
Q_FOREACH ( const QString &style, styles )
{
mFontStyleComboBox->addItem( style );
}

QString targetStyle = mFontDB.styleString( mRefFont );
if ( !styles.contains( targetStyle ) )
{
QFont f = QFont( mRefFont.family() );
targetStyle = QFontInfo( f ).styleName();
mRefFont.setStyleName( targetStyle );
}
int curIndx = 0;
int stylIndx = mFontStyleComboBox->findText( mFontDB.styleString( mRefFont ) );
int stylIndx = mFontStyleComboBox->findText( targetStyle );
if ( stylIndx > -1 )
{
curIndx = stylIndx;
Expand Down

0 comments on commit 012515c

Please sign in to comment.