Skip to content

Commit 78bd89d

Browse files
committed
Split multiline labels for dxf export
1 parent 82acf76 commit 78bd89d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/core/dxf/qgsdxfpallabeling.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,16 @@ void QgsDxfPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext&
7676
{
7777
line.append( QgsPoint( label->getX( i ), label->getY( i ) ) );
7878
}
79-
mDxfExport->writePolyline( line, layerName, "CONTINUOUS", 0, 1, true );*/
79+
mDxfExport->writePolyline( line, layerName, "CONTINUOUS", 1, 0.01, true );*/
8080

81-
mDxfExport->writeText( layerName, text, QgsPoint( label->getX(), label->getY() ), label->getHeight(), angle, mDxfExport->closestColorMatch( tmpLyr.textColor.rgb() ) );
81+
QStringList textList = text.split( "\n" );
82+
double textHeight = label->getHeight() / textList.size();
83+
QFontMetricsF fm( tmpLyr.textFont );
84+
double textAscent = textHeight * fm.ascent() / fm.height();
85+
86+
for ( int i = 0; i < textList.size(); ++i )
87+
{
88+
mDxfExport->writeText( layerName, textList.at( i ), QgsPoint( label->getX(), label->getY() + i * textHeight ), textAscent, angle, mDxfExport->closestColorMatch( tmpLyr.textColor.rgb() ) );
89+
}
8290
}
8391
}

0 commit comments

Comments
 (0)