mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-24 03:10:52 +01:00
Fix dxf export of autosize text cells in titleblock
This commit is contained in:
@@ -1833,29 +1833,20 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
||||
x2 = x;
|
||||
} else if ( cell.alignment & Qt::AlignBottom ) {}
|
||||
|
||||
|
||||
//painter.setFont(text_font);
|
||||
|
||||
qreal ratio = 1.0;
|
||||
if (cell.hadjust) {
|
||||
QFontMetricsF font_metrics(text_font);
|
||||
QRectF font_rect = font_metrics.boundingRect(
|
||||
QRect(-10000, -10000, 10000, 10000),
|
||||
cell.alignment,
|
||||
text);
|
||||
|
||||
if (font_rect.width()*Createdxf::xScale > w) {
|
||||
qreal ratio = qreal(w)
|
||||
/ qreal(font_rect.width()
|
||||
*Createdxf::xScale);
|
||||
textHeight *= ratio;
|
||||
// Scale font width to fit string in cell width w
|
||||
QFontMetricsF font_metrics(text_font);
|
||||
qreal textw = font_metrics.width(text)*Createdxf::xScale;
|
||||
if (textw > w) {
|
||||
ratio = (w / textw) * 0.8; // Allow some space around text in cell
|
||||
}
|
||||
}
|
||||
//TODO DAV 16AUG2020 - x & y offset values bellow (5 & 3) set heuristically for now, as are not exactly Diagram::margin = 5
|
||||
// fix when have a chance to work through the preceding scaling logic!
|
||||
// Also add/fix autosizing font to fit in cell
|
||||
// x & y offset values below (1 & 3) currently set heuristically based on appearance...
|
||||
Createdxf::drawTextAligned(file_path,
|
||||
text,
|
||||
x - 5*Createdxf::xScale,
|
||||
x - 1*Createdxf::xScale,
|
||||
y - 3*Createdxf::yScale,
|
||||
textHeight*Createdxf::yScale,
|
||||
0,
|
||||
@@ -1863,6 +1854,7 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
||||
hAlign,
|
||||
vAlign,
|
||||
x2,
|
||||
ratio,
|
||||
color,
|
||||
0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user