@@ -363,6 +363,7 @@ bool QgsLayoutItemLabel::writePropertiesToElement( QDomElement &layoutLabelElem,
363
363
fontColorElem.setAttribute ( QStringLiteral ( " red" ), mFontColor .red () );
364
364
fontColorElem.setAttribute ( QStringLiteral ( " green" ), mFontColor .green () );
365
365
fontColorElem.setAttribute ( QStringLiteral ( " blue" ), mFontColor .blue () );
366
+ fontColorElem.setAttribute ( QStringLiteral ( " alpha" ), mFontColor .alpha () );
366
367
layoutLabelElem.appendChild ( fontColorElem );
367
368
368
369
return true ;
@@ -408,7 +409,8 @@ bool QgsLayoutItemLabel::readPropertiesFromElement( const QDomElement &itemElem,
408
409
int red = fontColorElem.attribute ( QStringLiteral ( " red" ), QStringLiteral ( " 0" ) ).toInt ();
409
410
int green = fontColorElem.attribute ( QStringLiteral ( " green" ), QStringLiteral ( " 0" ) ).toInt ();
410
411
int blue = fontColorElem.attribute ( QStringLiteral ( " blue" ), QStringLiteral ( " 0" ) ).toInt ();
411
- mFontColor = QColor ( red, green, blue );
412
+ int alpha = fontColorElem.attribute ( QStringLiteral ( " alpha" ), QStringLiteral ( " 255" ) ).toInt ();
413
+ mFontColor = QColor ( red, green, blue, alpha );
412
414
}
413
415
else
414
416
{
@@ -580,7 +582,7 @@ QUrl QgsLayoutItemLabel::createStylesheetUrl() const
580
582
QString stylesheet;
581
583
stylesheet += QStringLiteral ( " body { margin: %1 %2;" ).arg ( std::max ( mMarginY * mHtmlUnitsToLayoutUnits , 0.0 ) ).arg ( std::max ( mMarginX * mHtmlUnitsToLayoutUnits , 0.0 ) );
582
584
stylesheet += QgsFontUtils::asCSS ( mFont , 0.352778 * mHtmlUnitsToLayoutUnits );
583
- stylesheet += QStringLiteral ( " color: %1 ;" ).arg ( mFontColor .name ( ) );
585
+ stylesheet += QStringLiteral ( " color: rgba(%1,%2,%3,%4) ;" ).arg ( mFontColor .red () ). arg ( mFontColor . green () ). arg ( mFontColor . blue () ). arg ( QString::number ( mFontColor . alphaF (), ' f ' , 4 ) );
584
586
stylesheet += QStringLiteral ( " text-align: %1; }" ).arg ( mHAlignment == Qt::AlignLeft ? QStringLiteral ( " left" ) : mHAlignment == Qt::AlignRight ? QStringLiteral ( " right" ) : mHAlignment == Qt::AlignHCenter ? QStringLiteral ( " center" ) : QStringLiteral ( " justify" ) );
585
587
586
588
QByteArray ba;
0 commit comments