Skip to content

Commit 769c82b

Browse files
committed
[pal] fix curved labels failure with zero-width characters
(fixes 15801)
1 parent a44ea22 commit 769c82b

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/core/pal/feature.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,10 @@ LabelPosition* FeaturePart::curvedPlacementAtOffset( PointSet* path_positions, d
10591059

10601060
// grab the next character according to the orientation
10611061
LabelInfo::CharacterInfo& ci = ( orientation > 0 ? li->char_info[i] : li->char_info[li->char_num-i-1] );
1062+
if ( qgsDoubleNear( ci.width, 0.0 ) )
1063+
// Certain scripts rely on zero-width character, skip those to prevent failure (see #15801)
1064+
continue;
1065+
10621066
double start_x, start_y, end_x, end_y;
10631067
if ( nextCharPosition( ci.width, path_distances[index], path_positions, index, distance, start_x, start_y, end_x, end_y ) == false )
10641068
{

tests/src/python/test_qgspallabeling_placement.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,18 @@ def test_label_line_avoid_jaggy(self):
433433
self.removeMapLayer(self.layer)
434434
self.layer = None
435435

436+
def test_label_curved_zero_width_char(self):
437+
# Test that curved label work with zero-width characters
438+
self.layer = TestQgsPalLabeling.loadFeatureLayer('line')
439+
self._TestMapSettings = self.cloneMapSettings(self._MapSettings)
440+
self.lyr.placement = QgsPalLayerSettings.Curved
441+
self.lyr.placementFlags = QgsPalLayerSettings.OnLine
442+
self.lyr.fieldName = "'invisible​space'"
443+
self.lyr.isExpression = True
444+
self.checkTest()
445+
self.removeMapLayer(self.layer)
446+
self.layer = None
447+
436448
if __name__ == '__main__':
437449
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
438450
# SEE: test_qgspallabeling_tests.suiteTests() to define suite

tests/src/python/test_qgspallabeling_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,9 @@ def test_curved_placement_below(self):
308308
self.lyr.placementFlags = QgsPalLayerSettings.BelowLine | QgsPalLayerSettings.MapOrientation
309309
self.checkTest()
310310

311-
312311
# noinspection PyPep8Naming
312+
313+
313314
def suiteTests():
314315
"""
315316
Use to define which tests are run when PAL_SUITE is set.

0 commit comments

Comments
 (0)