Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom tab distances for labels #59253

Merged
merged 7 commits into from
Nov 9, 2024
Merged

Conversation

nyalldawson
Copy link
Collaborator

Allows setting a list of custom tab stop distances, instead of just a single distance

Peek.2024-10-29.13-35.mp4

Sponsored by City of Freiburg im Breisgau

@nyalldawson nyalldawson added Feature Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Oct 29, 2024
@qgis-bot
Copy link
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@qgis-bot
Copy link
Collaborator

@nyalldawson
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions github-actions bot added this to the 3.42.0 milestone Oct 29, 2024
Copy link

github-actions bot commented Oct 29, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit e1f060f)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit c33fbe5)

@uclaros
Copy link
Contributor

uclaros commented Oct 29, 2024

Nice!!
What is the expected behavior when text does not fit within a tabstop?
For example something like

        format = QgsTextFormat()
        format.setFont(getTestFont('bold'))
        format.setSize(20)
        format.setSizeUnit(QgsUnitTypes.RenderUnit.RenderPoints)
        format.setTabPositions([QgsTextFormat.Tab(20), QgsTextFormat.Tab(24)])  # if 4mm are enough to fit a single letter
        format.setTabStopDistanceUnit(Qgis.RenderUnit.Millimeters)
        self.assertTrue(self.checkRender(format,
                                         'text_tab_positions_fixed_size',
                                         text=['with\tmany\ttabs', 'a\tb\tc']))

where the second line's b would fit but the first line's many would not fit.

@nyalldawson
Copy link
Collaborator Author

@uclaros

What is the expected behavior when text does not fit within a tabstop?

It just runs over the tab stop, and the next tab character will advance to the next available tab stop past the current position. And if there's no remaining explicit tab stops, then all remaining tab characters are ignored

@uclaros
Copy link
Contributor

uclaros commented Oct 29, 2024

Thanks, it makes sense! Maybe worth adding the test?

@nyalldawson
Copy link
Collaborator Author

@uclaros

Thanks, it makes sense! Maybe worth adding the test?

Ok, done

@qgis qgis deleted a comment from github-actions bot Oct 30, 2024
@DelazJ
Copy link
Contributor

DelazJ commented Oct 30, 2024

Hi,
I watched the screencast, and sorry for the noob question but, what would be the use case of this feature? IIUC it allows to add different tab spacing between words(?) within a label. But when would I want to do that? Any examples? Thanks.

@nyalldawson
Copy link
Collaborator Author

@DelazJ one cool use case is it allows the creation of table-like labels, because you can have multiline text with different "columns" of text lined up nicely.

@nyalldawson nyalldawson merged commit cf90076 into qgis:master Nov 9, 2024
30 of 31 checks passed
@nyalldawson nyalldawson deleted the custom_tab branch November 9, 2024 22:52
@qgis-bot
Copy link
Collaborator

qgis-bot commented Nov 9, 2024

@nyalldawson
A documentation ticket has been opened at qgis/QGIS-Documentation#9377
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog Items that are queued to appear in the visual changelog - remove after harvesting Feature Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants