[labeling] Curved labels are now angled per character

...instead of shifted along base line (fix #15210)
This commit is contained in:
Frits van Veen 2016-07-17 09:09:24 +02:00 committed by Nyall Dawson
parent 48f090ca79
commit f6d07a33b7
7 changed files with 10 additions and 3 deletions

View File

@ -879,6 +879,13 @@ LabelPosition* FeaturePart::curvedPlacementAtOffset( PointSet* path_positions, d
delete slp; delete slp;
return nullptr; return nullptr;
} }
// Shift the character downwards since the draw position is specified at the baseline
// and we're calculating the mean line here
double dist = 0.9 * li->label_height / 2;
if ( orientation < 0 )
dist = -dist;
start_x += dist * cos( angle + M_PI_2 );
start_y -= dist * sin( angle + M_PI_2 );
double render_angle = angle; double render_angle = angle;
@ -1042,11 +1049,11 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition* >& lPos,
double angle_avg = atan2( sin_avg / li->char_num, cos_avg / li->char_num ); double angle_avg = atan2( sin_avg / li->char_num, cos_avg / li->char_num );
// displacement // displacement
if (( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) ) ) if (( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) ) )
positions.append( _createCurvedCandidate( slp, angle_avg, mLF->distLabel() ) ); positions.append( _createCurvedCandidate( slp, angle_avg, mLF->distLabel() + li->label_height / 2 ) );
if ( flags & FLAG_ON_LINE ) if ( flags & FLAG_ON_LINE )
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height / 2 ) ); positions.append( _createCurvedCandidate( slp, angle_avg, 0 ) );
if (( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) ) ) if (( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) ) )
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height - mLF->distLabel() ) ); positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height / 2 - mLF->distLabel() ) );
// delete original candidate // delete original candidate
delete slp; delete slp;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 12 KiB