@@ -2302,6 +2302,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
2302
2302
2303
2303
// calculate rest of font attributes and store any data defined values
2304
2304
// this is done here for later use in making label backgrounds part of collision management (when implemented)
2305
+ labelFont.setCapitalization ( QFont::MixedCase ); // reset this - we don't use QFont's handling as it breaks with curved labels
2305
2306
parseTextStyle ( labelFont, fontunits, context );
2306
2307
parseTextFormatting ( context );
2307
2308
parseTextBuffer ( context );
@@ -2340,6 +2341,41 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
2340
2341
labelText = substitutions.process ( labelText );
2341
2342
}
2342
2343
2344
+ // apply capitalization
2345
+ QgsStringUtils::Capitalization capitalization = QgsStringUtils::MixedCase;
2346
+ // maintain API - capitalization may have been set in textFont
2347
+ if ( textFont.capitalization () != QFont::MixedCase )
2348
+ {
2349
+ capitalization = static_cast < QgsStringUtils::Capitalization >( textFont.capitalization () );
2350
+ }
2351
+ // data defined font capitalization?
2352
+ if ( dataDefinedEvaluate ( QgsPalLayerSettings::FontCase, exprVal, &context.expressionContext () ) )
2353
+ {
2354
+ QString fcase = exprVal.toString ().trimmed ();
2355
+ QgsDebugMsgLevel ( QString ( " exprVal FontCase:%1" ).arg ( fcase ), 4 );
2356
+
2357
+ if ( !fcase.isEmpty () )
2358
+ {
2359
+ if ( fcase.compare ( " NoChange" , Qt::CaseInsensitive ) == 0 )
2360
+ {
2361
+ capitalization = QgsStringUtils::MixedCase;
2362
+ }
2363
+ else if ( fcase.compare ( " Upper" , Qt::CaseInsensitive ) == 0 )
2364
+ {
2365
+ capitalization = QgsStringUtils::AllUppercase;
2366
+ }
2367
+ else if ( fcase.compare ( " Lower" , Qt::CaseInsensitive ) == 0 )
2368
+ {
2369
+ capitalization = QgsStringUtils::AllLowercase;
2370
+ }
2371
+ else if ( fcase.compare ( " Capitalize" , Qt::CaseInsensitive ) == 0 )
2372
+ {
2373
+ capitalization = QgsStringUtils::ForceFirstLetterToCapital;
2374
+ }
2375
+ }
2376
+ }
2377
+ labelText = QgsStringUtils::capitalize ( labelText, capitalization );
2378
+
2343
2379
// data defined format numbers?
2344
2380
bool formatnum = formatNumbers;
2345
2381
if ( dataDefinedEvaluate ( QgsPalLayerSettings::NumFormat, exprVal, &context.expressionContext (), formatNumbers ) )
@@ -3358,7 +3394,6 @@ void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
3358
3394
// copy over existing font settings
3359
3395
// newFont = newFont.resolve( labelFont ); // should work, but let's be sure what's being copied
3360
3396
newFont.setPixelSize ( labelFont.pixelSize () );
3361
- newFont.setCapitalization ( labelFont.capitalization () );
3362
3397
newFont.setUnderline ( labelFont.underline () );
3363
3398
newFont.setStrikeOut ( labelFont.strikeOut () );
3364
3399
newFont.setWordSpacing ( labelFont.wordSpacing () );
@@ -3395,39 +3430,6 @@ void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
3395
3430
}
3396
3431
labelFont.setLetterSpacing ( QFont::AbsoluteSpacing, scaleToPixelContext ( letterspace, context, fontunits, false , fontSizeMapUnitScale ) );
3397
3432
3398
- // data defined font capitalization?
3399
- QFont::Capitalization fontcaps = labelFont.capitalization ();
3400
- if ( dataDefinedEvaluate ( QgsPalLayerSettings::FontCase, exprVal, &context.expressionContext () ) )
3401
- {
3402
- QString fcase = exprVal.toString ().trimmed ();
3403
- QgsDebugMsgLevel ( QString ( " exprVal FontCase:%1" ).arg ( fcase ), 4 );
3404
-
3405
- if ( !fcase.isEmpty () )
3406
- {
3407
- if ( fcase.compare ( " NoChange" , Qt::CaseInsensitive ) == 0 )
3408
- {
3409
- fontcaps = QFont::MixedCase;
3410
- }
3411
- else if ( fcase.compare ( " Upper" , Qt::CaseInsensitive ) == 0 )
3412
- {
3413
- fontcaps = QFont::AllUppercase;
3414
- }
3415
- else if ( fcase.compare ( " Lower" , Qt::CaseInsensitive ) == 0 )
3416
- {
3417
- fontcaps = QFont::AllLowercase;
3418
- }
3419
- else if ( fcase.compare ( " Capitalize" , Qt::CaseInsensitive ) == 0 )
3420
- {
3421
- fontcaps = QFont::Capitalize;
3422
- }
3423
-
3424
- if ( fontcaps != labelFont.capitalization () )
3425
- {
3426
- labelFont.setCapitalization ( fontcaps );
3427
- }
3428
- }
3429
- }
3430
-
3431
3433
// data defined strikeout font style?
3432
3434
if ( dataDefinedEvaluate ( QgsPalLayerSettings::Strikeout, exprVal, &context.expressionContext (), labelFont.strikeOut () ) )
3433
3435
{
0 commit comments