Skip to content
Permalink
Browse files

[pal] fix curved labels failure with zero-width characters

(fixes 15801)
  • Loading branch information
nirvn committed Nov 3, 2016
1 parent a44ea22 commit 769c82b57964c41e0febe7d2848e0925b3e13f53
@@ -1059,6 +1059,10 @@ LabelPosition* FeaturePart::curvedPlacementAtOffset( PointSet* path_positions, d

// grab the next character according to the orientation
LabelInfo::CharacterInfo& ci = ( orientation > 0 ? li->char_info[i] : li->char_info[li->char_num-i-1] );
if ( qgsDoubleNear( ci.width, 0.0 ) )
// Certain scripts rely on zero-width character, skip those to prevent failure (see #15801)
continue;

double start_x, start_y, end_x, end_y;
if ( nextCharPosition( ci.width, path_distances[index], path_positions, index, distance, start_x, start_y, end_x, end_y ) == false )
{
@@ -433,6 +433,18 @@ def test_label_line_avoid_jaggy(self):
self.removeMapLayer(self.layer)
self.layer = None

def test_label_curved_zero_width_char(self):
# Test that curved label work with zero-width characters
self.layer = TestQgsPalLabeling.loadFeatureLayer('line')
self._TestMapSettings = self.cloneMapSettings(self._MapSettings)
self.lyr.placement = QgsPalLayerSettings.Curved
self.lyr.placementFlags = QgsPalLayerSettings.OnLine
self.lyr.fieldName = "'invisible​space'"
self.lyr.isExpression = True
self.checkTest()
self.removeMapLayer(self.layer)
self.layer = None

if __name__ == '__main__':
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
# SEE: test_qgspallabeling_tests.suiteTests() to define suite
@@ -308,8 +308,9 @@ def test_curved_placement_below(self):
self.lyr.placementFlags = QgsPalLayerSettings.BelowLine | QgsPalLayerSettings.MapOrientation
self.checkTest()


# noinspection PyPep8Naming


def suiteTests():
"""
Use to define which tests are run when PAL_SUITE is set.
Binary file not shown.

0 comments on commit 769c82b

Please sign in to comment.
You can’t perform that action at this time.