Multiline Labels are not properly displayed when a translation is applied to a pdf WMS Request

Description

I am trying to create a pdf print of a WMS Layer using self defined templates.

In order to achieve it the WMS Map content must be rendered within my own defined viewport. A translation is therefore applied to the whole map content in order to displace the generated pdf map to my template wiewport.
It works as expected, but only multi lines texts are not rendered to the correct place. All other geometries are correctly displaced.
I already investigated this issue and found out that the error is located in the LabelPainter.paintStraightLabel() Geotools method.

At the beginning, following statements create a new transformation to apply to the graphics object:

AffineTransform newTransform = new AffineTransform(oldTransform);
newTransform.concatenate(transform);
graphics.setTransform(newTransform);

But for multiline labels not this new calculated transformation is applied to each line as the following statements show:

// draw the label
if (lines.size() == 1) {
drawGlyphVector(lines.get(0).gv);
} else {
// for multiline labels we have to go thru the lines and apply
// the proper transformation
// to position each row within the label bounds
AffineTransform lineTx = new AffineTransform(transform);
for (LineInfo line : lines) {
lineTx.setTransform(transform); // <-- SHOULD BE lineTx.setTransform(newTransform) !
lineTx.translate(line.x, line.y);
graphics.setTransform(lineTx);
drawGlyphVector(line.gv);
}
}

Therefore, the multiline labels are all not rendered at the correct position.

Environment

None

Status

Assignee

Andrea Aime

Reporter

Hervé Minko

Triage

None

Fix versions

Affects versions

2.4.8

Components

Priority

High
Configure