Skip to content

Commit c95e08f

Browse files
committed
[labeling] Curved labels are now angled per character
...instead of shifted along base line (fix #15210) (cherry-picked from 22fdb6a)
1 parent e307032 commit c95e08f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/core/pal/feature.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,13 @@ LabelPosition* FeaturePart::curvedPlacementAtOffset( PointSet* path_positions, d
879879
delete slp;
880880
return nullptr;
881881
}
882+
// Shift the character downwards since the draw position is specified at the baseline
883+
// and we're calculating the mean line here
884+
double dist = 0.9 * li->label_height / 2;
885+
if ( orientation < 0 )
886+
dist = -dist;
887+
start_x += dist * cos( angle + M_PI_2 );
888+
start_y -= dist * sin( angle + M_PI_2 );
882889

883890
double render_angle = angle;
884891

@@ -1042,11 +1049,11 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition* >& lPos,
10421049
double angle_avg = atan2( sin_avg / li->char_num, cos_avg / li->char_num );
10431050
// displacement
10441051
if (( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) ) )
1045-
positions.append( _createCurvedCandidate( slp, angle_avg, mLF->distLabel() ) );
1052+
positions.append( _createCurvedCandidate( slp, angle_avg, mLF->distLabel() + li->label_height / 2 ) );
10461053
if ( flags & FLAG_ON_LINE )
1047-
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height / 2 ) );
1054+
positions.append( _createCurvedCandidate( slp, angle_avg, 0 ) );
10481055
if (( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) ) )
1049-
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height - mLF->distLabel() ) );
1056+
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height / 2 - mLF->distLabel() ) );
10501057

10511058
// delete original candidate
10521059
delete slp;

0 commit comments

Comments
 (0)