Navigation Menu

Skip to content

Commit

Permalink
Fix for double point size in font named-style lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
dakcarto committed Sep 3, 2012
1 parent 7870603 commit d2f08c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/app/qgslabelinggui.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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;
Expand All @@ -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() )
{
Expand All @@ -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() );
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/core/qgspallabeling.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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() );
Expand Down

0 comments on commit d2f08c6

Please sign in to comment.