@@ -47,7 +47,6 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
47
47
48
48
connect ( btnTextColor, SIGNAL ( clicked () ), this , SLOT ( changeTextColor () ) );
49
49
connect ( btnChangeFont, SIGNAL ( clicked () ), this , SLOT ( changeTextFont () ) );
50
- connect ( mFontSizeUnitComboBox , SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( updatePreview () ) );
51
50
connect ( mFontTranspSpinBox , SIGNAL ( valueChanged ( int ) ), this , SLOT ( updatePreview () ) );
52
51
connect ( chkBuffer, SIGNAL ( toggled ( bool ) ), this , SLOT ( updatePreview () ) );
53
52
connect ( btnBufferColor, SIGNAL ( clicked () ), this , SLOT ( changeBufferColor () ) );
@@ -512,6 +511,8 @@ void QgsLabelingGui::changeTextFont()
512
511
{
513
512
// store properties of QFont that might be stripped by font dialog
514
513
QFont::Capitalization captials = mRefFont .capitalization ();
514
+ double wordspacing = mRefFont .wordSpacing ();
515
+ double letterspacing = mRefFont .letterSpacing ();
515
516
516
517
bool ok;
517
518
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
@@ -534,6 +535,8 @@ void QgsLabelingGui::changeTextFont()
534
535
535
536
// reassign possibly stripped QFont properties
536
537
font.setCapitalization ( captials );
538
+ font.setWordSpacing ( wordspacing );
539
+ font.setLetterSpacing ( QFont::AbsoluteSpacing, letterspacing );
537
540
538
541
updateFont ( font );
539
542
}
@@ -569,6 +572,8 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle )
569
572
styledfont.setCapitalization ( mRefFont .capitalization () );
570
573
styledfont.setUnderline ( mRefFont .underline () );
571
574
styledfont.setStrikeOut ( mRefFont .strikeOut () );
575
+ styledfont.setWordSpacing ( mRefFont .wordSpacing () );
576
+ styledfont.setLetterSpacing ( QFont::AbsoluteSpacing, mRefFont .letterSpacing () );
572
577
mRefFont = styledfont;
573
578
}
574
579
// if no match, style combobox will be left blank, which should not affect engine labeling
@@ -611,6 +616,8 @@ void QgsLabelingGui::updateFont( QFont font )
611
616
mFontCapitalsComboBox ->setCurrentIndex ( idx == -1 ? 0 : idx );
612
617
mFontUnderlineBtn ->setChecked ( mRefFont .underline () );
613
618
mFontStrikethroughBtn ->setChecked ( mRefFont .strikeOut () );
619
+ mFontWordSpacingSpinBox ->setValue ( mRefFont .wordSpacing () );
620
+ mFontLetterSpacingSpinBox ->setValue ( mRefFont .letterSpacing () );
614
621
blockFontChangeSignals ( false );
615
622
616
623
// update font name with font face
@@ -633,6 +640,7 @@ void QgsLabelingGui::updatePreview()
633
640
lblFontPreview->setFont ( mRefFont );
634
641
QFont previewFont = lblFontPreview->font ();
635
642
double fontSize = mFontSizeSpinBox ->value ();
643
+ double previewRatio = mPreviewSize / fontSize;
636
644
double bufferSize = 0.0 ;
637
645
QString grpboxtitle;
638
646
@@ -643,11 +651,14 @@ void QgsLabelingGui::updatePreview()
643
651
mPreviewSizeSlider ->setEnabled ( true );
644
652
grpboxtitle = tr ( " Sample @ %1 pts (using map units)" ).arg ( mPreviewSize );
645
653
654
+ previewFont.setWordSpacing ( previewRatio * mFontWordSpacingSpinBox ->value () );
655
+ previewFont.setLetterSpacing ( QFont::AbsoluteSpacing, previewRatio * mFontLetterSpacingSpinBox ->value () );
656
+
646
657
if ( chkBuffer->isChecked () )
647
658
{
648
659
if ( mBufferUnitComboBox ->currentIndex () == 1 ) // map units
649
660
{
650
- bufferSize = ( mPreviewSize / fontSize ) * spinBufferSize->value () / 2.5 ;
661
+ bufferSize = previewRatio * spinBufferSize->value () / 3.527 ;
651
662
}
652
663
else // millimeters
653
664
{
@@ -850,6 +861,15 @@ void QgsLabelingGui::on_mFontLetterSpacingSpinBox_valueChanged( double spacing )
850
861
updateFont ( mRefFont );
851
862
}
852
863
864
+ void QgsLabelingGui::on_mFontSizeUnitComboBox_currentIndexChanged ( int index )
865
+ {
866
+ double singleStep = ( index == 1 ) ? 10.0 : 1.0 ; // 10 for map units, 1 for mm
867
+ mFontSizeSpinBox ->setSingleStep ( singleStep );
868
+ mFontWordSpacingSpinBox ->setSingleStep ( singleStep );
869
+ mFontLetterSpacingSpinBox ->setSingleStep ( singleStep / 10 );
870
+ updateFont ( mRefFont );
871
+ }
872
+
853
873
void QgsLabelingGui::on_mBufferUnitComboBox_currentIndexChanged ( int index )
854
874
{
855
875
double singleStep = ( index == 1 ) ? 1.0 : 0.1 ; // 1.0 for map units, 0.1 for mm
0 commit comments