summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2024-03-15 12:25:41 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2024-03-18 20:28:36 +0100
commite205edfff611922ddf04d8de71ed9cb92704eafc (patch)
tree791c3eea2b026124d031798f147b1142e6eb5745 /src/gui/text/qtextdocument.cpp
parent58796ac177cde3f558aec92c00e7ee8e174ba228 (diff)
Implement support for stroke color and width in CSS parser
CSS does not have text outline properties, instead different browsers have custom properties for this. That currently means that you can have a QTextDocument where you applied a stroke to text and textEdit.setHtml(textEdit.toHtml()) will remove it. Since a primary goal of the HTML support in QTextDocument is that it can be used to save and faithfully restore its contents, we implement qt specific properties for stroke. Task-number: QTBUG-123357 Change-Id: Id9cf63abfabe2109ffb6fd74f9cb013304763ccb Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r--src/gui/text/qtextdocument.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index b5dd8c2b83..dc94643e8a 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2701,6 +2701,18 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)
attributesEmitted = true;
}
+ if (format.hasProperty(QTextFormat::TextOutline)) {
+ QPen outlinePen = format.textOutline();
+ html += " -qt-stroke-color:"_L1;
+ html += colorValue(outlinePen.color());
+ html += u';';
+
+ html += " -qt-stroke-width:"_L1;
+ html += QString::number(outlinePen.widthF());
+ html += "px;"_L1;
+ attributesEmitted = true;
+ }
+
return attributesEmitted;
}