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

newly added "letter spacing" and "word spacing" label values ignored when setting placement to curved (on line layer) #15784

Closed
qgib opened this issue Oct 31, 2012 · 5 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Labeling Related to QGIS map labeling
Milestone

Comments

@qgib
Copy link
Contributor

qgib commented Oct 31, 2012

Author Name: Mathieu Pellerin - nIRV (Mathieu Pellerin - nIRV)
Original Redmine Issue: 6593
Affected QGIS version: master
Redmine category:labelling
Assignee: Larry Shaffer


Subject says it all. The letter spacing and word spacing values are ignored when the placement is set to curved on line layers.

@qgib
Copy link
Contributor Author

qgib commented Oct 31, 2012

Author Name: Larry Shaffer (Larry Shaffer)


Hi,

They aren't ignored, they're just not implemented yet. :^) Currently, multi-line labels and direction symbol are also non-functional for curved labels. See [[New Labeling changes and roadmap]]

The problem is with how the PAL engine creates curved labels. Basically, it chops up the text into individual characters, creating a single label comprised of multiple smaller labels. Since each character is a label unto itself, there is no actual letter or word spacing. The base of each letter is 'chained' to the previous one. Turn on 'show candidates' under Automated placement settings to see this.

There are several solutions I'm looking at:

  • Fake it - Keeping PAL's curved label current output, and concerning character spacing, the passed-in QFontMetricsF to PAL can possibly be manipulated with faux letter stretching or font sizing to mimic the appropriately scaled character spacing. Word spacing would be a bit trickier. This method is more of a hack than a fix, and actually used to be able to be used when there was a bug allowing layer-level font size to be used by PAL, but font size was data defined and used to draw the label (i.e. larger layer-level font size would add letter spacing).

  • Fix it in PAL lib - Pass in the letter and word spacing options and adjust the calculations directly. A little complicated, but the right thing to do.

  • Change the output - Using the calculated output from PAL, return a path feature that is essentially the base edge of each chained individual character label. Use the returned path, with possibly some slight simplification, as the path on which to draw the whole label. This allows more control using Qt, from outside PAL, to handle the drawing.
    However, that means doing multiple calculations per curved label (slowing rendering down), but possibly offers a more flexible solution to this and other curved labeling issues.

Some methods of drawing the text on the resultant path:

http://qt-project.org/faq/answer/how_do_i_make_text_follow_the_line_curve_and_angle_of_the_qpainterpath


  • fixed_version_id was configured as Version 2.0.0
  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Nov 1, 2012

Author Name: Mathieu Pellerin - nIRV (Mathieu Pellerin - nIRV)


Larry, depending on how hard / long it'd take to implement any of the above listed options, maybe it'd be good to at least provide a hint to the users that the values are not taken into account. Disabling the input fields for these two settings when the curved placement is selected might be a good way to do that.

@qgib
Copy link
Contributor Author

qgib commented Nov 1, 2012

Author Name: Larry Shaffer (Larry Shaffer)


Ok. I'll look at doing that ASAP.

@qgib
Copy link
Contributor Author

qgib commented Nov 7, 2012

Author Name: Larry Shaffer (Larry Shaffer)


@nirvn,

Implemented in commit 59fe8fd. Please test.

The solution opted for was a variation on Fix it in PAL lib, which works within QgsPalGeometry to mimic Qt-derived letter/word spacing and storing it in the associated pal::LabelInfo. PAL lib uses that to figure the width of each character it 'chops up' and generates candidates for. While character spacing worked right away, word spacing was much trickier to implement so it mimicked the other label placements that accomplish spacing via direct Qt support.


  • status_id was changed from Feedback to In Progress
  • resolution was changed from to fixed
  • assigned_to_id was configured as Larry Shaffer

@qgib
Copy link
Contributor Author

qgib commented Nov 11, 2012

Author Name: Mathieu Pellerin - nIRV (Mathieu Pellerin - nIRV)


Kudos Larry, it's working beautifully.


  • done_ratio was changed from 0 to 100
  • status_id was changed from In Progress to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Labeling Related to QGIS map labeling labels May 24, 2019
@qgib qgib added this to the Version 2.0.0 milestone May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Labeling Related to QGIS map labeling
Projects
None yet
Development

No branches or pull requests

1 participant