Skip to content

Commit

Permalink
Fix handling of multiple consecutive tabs with HTML text rendering
Browse files Browse the repository at this point in the history
Refs #60098
  • Loading branch information
nyalldawson committed Jan 28, 2025
1 parent 6ca5140 commit 58591ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/textrenderer/qgstextdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ QgsTextDocument QgsTextDocument::fromPlainText( const QStringList &lines )
// Note -- must start and end with spaces, so that a tab character within
// a html or css tag doesn't mess things up. Instead, Qt will just silently
// ignore html attributes it doesn't know about, like this replacement string
#define TAB_REPLACEMENT_MARKER " ignore_me_i_am_a_tab "
#define TAB_REPLACEMENT_MARKER "!ignore_me_i_am_a_tab!"

QgsTextDocument QgsTextDocument::fromHtml( const QStringList &lines )
{
Expand Down
14 changes: 14 additions & 0 deletions tests/src/python/test_qgstextrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3656,6 +3656,20 @@ def testDrawTabFixedSize(self):
self.checkRender(format, "text_tab_fixed_size", text=["with\ttabs", "a\tb"])
)

def testDrawTabsMultipleHtmlFixedSize(self):
format = QgsTextFormat()
format.setFont(getTestFont("bold"))
format.setSize(20)
format.setAllowHtmlFormatting(True)
format.setSizeUnit(QgsUnitTypes.RenderUnit.RenderPoints)
format.setTabStopDistance(20)
format.setTabStopDistanceUnit(Qgis.RenderUnit.Millimeters)
self.assertTrue(
self.checkRender(
format, "text_tab_multiple_html", text=["with\t\ttabs", "a\t\tb"]
)
)

def testDrawTabPositionsFixedSize(self):
format = QgsTextFormat()
format.setFont(getTestFont("bold"))
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 58591ae

Please sign in to comment.