Bug report #6593
newly added "letter spacing" and "word spacing" label values ignored when setting placement to curved (on line layer)
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | Larry Shaffer | ||
Category: | Labelling | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | fixed |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 15784 |
Description
Subject says it all. The letter spacing and word spacing values are ignored when the placement is set to curved on line layers.
History
#1 Updated by Larry Shaffer about 12 years ago
- Target version set to Version 2.0.0
- Status changed from Open to Feedback
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:
#2 Updated by Mathieu Pellerin - nIRV about 12 years ago
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.
#3 Updated by Larry Shaffer about 12 years ago
Ok. I'll look at doing that ASAP.
#4 Updated by Larry Shaffer almost 12 years ago
- Status changed from Feedback to In Progress
- Resolution set to fixed
- Assignee set to 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.
#5 Updated by Mathieu Pellerin - nIRV almost 12 years ago
- % Done changed from 0 to 100
- Status changed from In Progress to Closed
Kudos Larry, it's working beautifully.