Skip to content

Commit d2f08c6

Browse files
committedSep 3, 2012
Fix for double point size in font named-style lookups
1 parent 7870603 commit d2f08c6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed
 

‎src/app/qgslabelinggui.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
221221
}
222222

223223
mRefFont = lyr.textFont;
224-
mFontSizeSpinBox->setValue( mRefFont.pointSizeF() );
224+
mFontSizeSpinBox->setValue( lyr.textFont.pointSizeF() );
225225
btnTextColor->setColor( lyr.textColor );
226226
mFontTranspSpinBox->setValue( lyr.textTransp );
227227

@@ -583,9 +583,11 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle )
583583
{
584584
QFont styledfont;
585585
bool foundmatch = false;
586+
int fontSize = 12; // QFontDatabase::font() needs an integer for size
586587
if ( !fontstyle.isEmpty() )
587588
{
588-
styledfont = mFontDB.font( mRefFont.family(), fontstyle, mRefFont.pointSizeF() );
589+
styledfont = mFontDB.font( mRefFont.family(), fontstyle, fontSize );
590+
styledfont.setPointSizeF( mRefFont.pointSizeF() );
589591
if ( QApplication::font().toString() != styledfont.toString() )
590592
{
591593
foundmatch = true;
@@ -595,7 +597,8 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle )
595597
{
596598
foreach ( const QString &style, mFontDB.styles( mRefFont.family() ) )
597599
{
598-
styledfont = mFontDB.font( mRefFont.family(), style, mRefFont.pointSizeF() );
600+
styledfont = mFontDB.font( mRefFont.family(), style, fontSize );
601+
styledfont.setPointSizeF( mRefFont.pointSizeF() );
599602
styledfont = styledfont.resolve( mRefFont );
600603
if ( mRefFont.toString() == styledfont.toString() )
601604
{
@@ -606,6 +609,7 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle )
606609
}
607610
if ( foundmatch )
608611
{
612+
// styledfont.setPointSizeF( mRefFont.pointSizeF() );
609613
styledfont.setCapitalization( mRefFont.capitalization() );
610614
styledfont.setUnderline( mRefFont.underline() );
611615
styledfont.setStrikeOut( mRefFont.strikeOut() );
@@ -629,7 +633,7 @@ void QgsLabelingGui::updateFont( QFont font )
629633
bool missing = false;
630634
if ( QApplication::font().toString() != mRefFont.toString() )
631635
{
632-
QFont testfont = mFontDB.font( mRefFont.family(), mFontDB.styleString( mRefFont ), mRefFont.pointSizeF() );
636+
QFont testfont = mFontDB.font( mRefFont.family(), mFontDB.styleString( mRefFont ), 12 );
633637
if ( QApplication::font().toString() == testfont.toString() )
634638
{
635639
missing = true;
@@ -667,8 +671,11 @@ void QgsLabelingGui::updateFont( QFont font )
667671
void QgsLabelingGui::blockFontChangeSignals( bool blk )
668672
{
669673
mFontStyleComboBox->blockSignals( blk );
674+
mFontCapitalsComboBox->blockSignals( blk );
670675
mFontUnderlineBtn->blockSignals( blk );
671676
mFontStrikethroughBtn->blockSignals( blk );
677+
mFontWordSpacingSpinBox->blockSignals( blk );
678+
mFontLetterSpacingSpinBox->blockSignals( blk );
672679
}
673680

674681
void QgsLabelingGui::updatePreview()

‎src/core/qgspallabeling.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ void QgsPalLayerSettings::updateFontViaStyle( const QString & fontstyle )
338338
{
339339
if ( !fontstyle.isEmpty() )
340340
{
341-
QFont styledfont = mFontDB.font( textFont.family(), fontstyle, textFont.pointSizeF() );
341+
QFont styledfont = mFontDB.font( textFont.family(), fontstyle, 12 );
342+
styledfont.setPointSizeF( textFont.pointSizeF() );
342343
if ( QApplication::font().toString() != styledfont.toString() )
343344
{
344345
textFont = styledfont;
@@ -367,7 +368,7 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
367368
textFont = QFont( fontFamily, fontSize, fontWeight, fontItalic );
368369
textFont.setPointSizeF( fontSize ); //double precision needed because of map units
369370
textNamedStyle = layer->customProperty( "labeling/namedStyle", QVariant( "" ) ).toString();
370-
updateFontViaStyle( textNamedStyle );
371+
updateFontViaStyle( textNamedStyle ); // must come after textFont.setPointSizeF()
371372
textFont.setCapitalization(( QFont::Capitalization ) layer->customProperty( "labeling/fontCapitals", QVariant( 0 ) ).toUInt() );
372373
textFont.setUnderline( layer->customProperty( "labeling/fontUnderline" ).toBool() );
373374
textFont.setStrikeOut( layer->customProperty( "labeling/fontStrikeout" ).toBool() );

0 commit comments

Comments
 (0)
Please sign in to comment.