mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Fix vertical alignment in data defined labeling
This commit is contained in:
parent
d94ecd3746
commit
5ab0df5262
@ -2029,25 +2029,28 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
|
||||
{
|
||||
QString valiString = exprVal.toString();
|
||||
QgsDebugMsgLevel( QString( "exprVal Vali:%1" ).arg( valiString ), 4 );
|
||||
|
||||
if ( valiString.compare( "Bottom", Qt::CaseInsensitive ) != 0 )
|
||||
{
|
||||
if ( valiString.compare( "Top", Qt::CaseInsensitive ) == 0
|
||||
|| valiString.compare( "Cap", Qt::CaseInsensitive ) == 0 )
|
||||
if ( valiString.compare( "Top", Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
ydiff -= labelY;
|
||||
}
|
||||
else
|
||||
{
|
||||
double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
|
||||
|
||||
if ( valiString.compare( "Base", Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
ydiff -= labelY * descentRatio;
|
||||
}
|
||||
else if ( valiString.compare( "Half", Qt::CaseInsensitive ) == 0 )
|
||||
else //'Cap' or 'Half'
|
||||
{
|
||||
ydiff -= labelY * descentRatio;
|
||||
ydiff -= labelY * 0.5 * ( 1 - descentRatio );
|
||||
double capHeightRatio = ( labelFontMetrics->boundingRect( 'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
|
||||
ydiff -= labelY * capHeightRatio;
|
||||
if ( valiString.compare( "Half", Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user