summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2024-02-05 22:53:22 -0700
committerShawn Rutledge <shawn.rutledge@qt.io>2024-02-14 18:36:42 -0700
commitbf8167c5fc513861ba9ecadf491db256de65eafd (patch)
treec8c7236e57882279d3ccf5b84d5ba67f9956b3ec /src/gui/text
parent1f6d7cbb341bd79826d3f6d69e1f1a427ebb8f1b (diff)
tst_QTextMarkdownWriter: test both ways of setting font characteristics
We have explicit QFont properties, and QTextFormat::setProperty(). Setting FontFixedPitch doesn't necessarily affect the view (QTextEdit or Qt Quick Text/TextEdit); and setting the font to the one we get from QFontDatabase::systemFont(QFontDatabase::FixedFont) is also unreliable, because the "monospace" fallback might actually be proportional. QTextMarkdownWriter checks for both to decide whether to use backticks; so markdown writing works if an editor UI makes the format monospace both ways to be safe. But in the opposite case that the main font is actually a monospace font, it's always been broken. The rest of the QTextCharFormat properties are generally working, to the extent that they are applicable to Markdown. But we lacked explicit test coverage: so far we were just reading Markdown or HTML and writing Markdown to test the writer. Also amend an old comment about writing underlines: writing was always possible, and since f5c7799f59ba53c634906b11e2135190093bf87b reading is supported too. So the underline support is symmetric (except that we don't heed the QTextDocument::MarkdownFeatures argument to the writer ctor: we probably should do that some day). Pick-to: 6.7 Task-number: QTBUG-54623 Task-number: QTBUG-75648 Task-number: QTBUG-75649 Task-number: QTBUG-79900 Task-number: QTBUG-99676 Task-number: QTBUG-103484 Change-Id: Iacb4ed0ea59030570702d4eadfdadfad872065c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index 011658d2d9..64dd88d82c 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -588,9 +588,9 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
endingMarkers = true;
}
if (fontInfo.underline() != underline) {
- // Markdown doesn't support underline, but the parser will treat a single underline
- // the same as a single asterisk, and the marked fragment will be rendered in italics.
- // That will have to do.
+ // CommonMark specifies underline as another way to get emphasis (italics):
+ // https://spec.commonmark.org/0.31.2/#example-148
+ // but md4c allows us to distinguish them; so we support underlining (in GitHub dialect).
markers += u'_';
underline = fontInfo.underline();
if (!underline)