Skip to content
Permalink
Browse files

Fix for double point size in font named-style lookups

  • Loading branch information
dakcarto committed Sep 3, 2012
1 parent 7870603 commit d2f08c60d923076f182b823a2a364be53ddc6504
Showing with 14 additions and 6 deletions.
  1. +11 −4 src/app/qgslabelinggui.cpp
  2. +3 −2 src/core/qgspallabeling.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()
@@ -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() );

0 comments on commit d2f08c6

Please sign in to comment.
You can’t perform that action at this time.