Skip to content
Permalink
Browse files
[labeling] When changing font families, reset to correct regular/book
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 012515c3e64f10a5495c32939e526fcda16b52dc
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/gui/qgstextformatwidget.cpp
@@ -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;

0 comments on commit 012515c

Please sign in to comment.