diff --git a/src/app/qgslabelinggui.cpp b/src/app/qgslabelinggui.cpp index c0a199272e19..1e886d87dd3d 100644 --- a/src/app/qgslabelinggui.cpp +++ b/src/app/qgslabelinggui.cpp @@ -221,7 +221,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM } mRefFont = lyr.textFont; - mFontSizeSpinBox->setValue( mRefFont.pointSizeF() ); + mFontSizeSpinBox->setValue( lyr.textFont.pointSizeF() ); btnTextColor->setColor( lyr.textColor ); mFontTranspSpinBox->setValue( lyr.textTransp ); @@ -583,9 +583,11 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle ) { QFont styledfont; bool foundmatch = false; + int fontSize = 12; // QFontDatabase::font() needs an integer for size if ( !fontstyle.isEmpty() ) { - styledfont = mFontDB.font( mRefFont.family(), fontstyle, mRefFont.pointSizeF() ); + styledfont = mFontDB.font( mRefFont.family(), fontstyle, fontSize ); + styledfont.setPointSizeF( mRefFont.pointSizeF() ); if ( QApplication::font().toString() != styledfont.toString() ) { foundmatch = true; @@ -595,7 +597,8 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle ) { foreach ( const QString &style, mFontDB.styles( mRefFont.family() ) ) { - styledfont = mFontDB.font( mRefFont.family(), style, mRefFont.pointSizeF() ); + styledfont = mFontDB.font( mRefFont.family(), style, fontSize ); + styledfont.setPointSizeF( mRefFont.pointSizeF() ); styledfont = styledfont.resolve( mRefFont ); if ( mRefFont.toString() == styledfont.toString() ) { @@ -606,6 +609,7 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle ) } if ( foundmatch ) { +// styledfont.setPointSizeF( mRefFont.pointSizeF() ); styledfont.setCapitalization( mRefFont.capitalization() ); styledfont.setUnderline( mRefFont.underline() ); styledfont.setStrikeOut( mRefFont.strikeOut() ); @@ -629,7 +633,7 @@ void QgsLabelingGui::updateFont( QFont font ) bool missing = false; if ( QApplication::font().toString() != mRefFont.toString() ) { - QFont testfont = mFontDB.font( mRefFont.family(), mFontDB.styleString( mRefFont ), mRefFont.pointSizeF() ); + QFont testfont = mFontDB.font( mRefFont.family(), mFontDB.styleString( mRefFont ), 12 ); if ( QApplication::font().toString() == testfont.toString() ) { missing = true; @@ -667,8 +671,11 @@ void QgsLabelingGui::updateFont( QFont font ) void QgsLabelingGui::blockFontChangeSignals( bool blk ) { mFontStyleComboBox->blockSignals( blk ); + mFontCapitalsComboBox->blockSignals( blk ); mFontUnderlineBtn->blockSignals( blk ); mFontStrikethroughBtn->blockSignals( blk ); + mFontWordSpacingSpinBox->blockSignals( blk ); + mFontLetterSpacingSpinBox->blockSignals( blk ); } void QgsLabelingGui::updatePreview() diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index 2838311d8536..d19cfed3365a 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -338,7 +338,8 @@ void QgsPalLayerSettings::updateFontViaStyle( const QString & fontstyle ) { if ( !fontstyle.isEmpty() ) { - QFont styledfont = mFontDB.font( textFont.family(), fontstyle, textFont.pointSizeF() ); + QFont styledfont = mFontDB.font( textFont.family(), fontstyle, 12 ); + styledfont.setPointSizeF( textFont.pointSizeF() ); if ( QApplication::font().toString() != styledfont.toString() ) { textFont = styledfont; @@ -367,7 +368,7 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer ) textFont = QFont( fontFamily, fontSize, fontWeight, fontItalic ); textFont.setPointSizeF( fontSize ); //double precision needed because of map units textNamedStyle = layer->customProperty( "labeling/namedStyle", QVariant( "" ) ).toString(); - updateFontViaStyle( textNamedStyle ); + updateFontViaStyle( textNamedStyle ); // must come after textFont.setPointSizeF() textFont.setCapitalization(( QFont::Capitalization ) layer->customProperty( "labeling/fontCapitals", QVariant( 0 ) ).toUInt() ); textFont.setUnderline( layer->customProperty( "labeling/fontUnderline" ).toBool() ); textFont.setStrikeOut( layer->customProperty( "labeling/fontStrikeout" ).toBool() );