View Issue Details

IDProjectCategoryView StatusLast Update
0017453ScribusText Frames / Story Editorpublic2026-11-04 12:46
Reporterale Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version1.7.1.svn 
Summary0017453: Adjust frame to height of text does not work correctly if the last line does not have descents and align to baseline is on
DescriptionWhen the text is aligned to the baseline, If the last line of a frame does not have any descent (j,g,...), adjusting the height of the frame to the text removes one line.

This ticket is extracted from 0012190
TagsNo tags attached.
Attached Files
adjust-frame-height.gif (104,623 bytes)   
adjust-frame-height.gif (104,623 bytes)   
PatchNo

Relationships

related to 0014668 new Adjust frame height to text fails if frame is not tall enough to display text. 
related to 0015153 confirmed "Adjust Frame Height to Text" does not always work 
related to 0017145 new Adjust Frame Height To Text / Text Frame Overflow Detection Interaction 
related to 0016187 new "adjust frame to content": merge adjusting to image and to text 

Activities

utnik

2026-11-04 04:22

updater   ~0054645

issue is still present in scribus 1.6.7 and 1.7.4. (and annoying…)

buttar

2026-11-04 12:46

reporter   ~0054647

The patch addresses the reported baseline-grid issue and an additional height-calculation issue identified during investigation.

## Fixes
- Original issue: With baseline-grid alignment, adjusting a text frame's height can incorrectly push the last line into overflow when it contains no descenders. The calculation now accommodates the full line height.
- Additional fix: When Do not split paragraph pushes an entire paragraph into overflow, the height calculation can still include its removed lines, leaving unnecessary empty space below the preceding paragraph. The calculation now excludes those lines, allowing the frame to shrink correctly to fit the remaining visible text.

Both corrections preserve existing Undo/Redo behaviour.

Validation: Both scenarios tested successfully. Based on pristine r27933, with no additional dependencies.
adjust-frame-height-to-text-v1.01.patch (1,636 bytes)   
Index: scribus/pageitem_textframe.cpp
===================================================================
--- scribus/pageitem_textframe.cpp	(revision 27933)
+++ scribus/pageitem_textframe.cpp	(working copy)
@@ -1193,6 +1193,24 @@
 			// push this paragraph to the next frame
 			for (int i = 0; i < pull; ++i)
 				textLayout.removeLastLine();
+			// Discard the extent contributed by lines pulled from this frame.
+			double remainingMaxY = 0.0;
+			const uint lineCount = textLayout.lines();
+			for (uint i = 0; i < lineCount; ++i)
+			{
+				const LineBox* line = textLayout.line(i);
+				double descent = -line->descent();
+				for (const Box* box : line->boxes())
+				{
+					if (box->type() == Box::T_Glyph)
+					{
+						const CharStyle& charStyle = static_cast<const GlyphBox*>(box)->style();
+						descent = qMax(descent, -charStyle.font().descent(charStyle.fontSize() / 10.0));
+					}
+				}
+				remainingMaxY = qMax(remainingMaxY, line->y() + line->ascent() + descent);
+			}
+			maxY = qMin(maxY, remainingMaxY);
 			m_maxChars = incompletePositions[incompleteLines-pull];
 			incompleteLines = 0;
 			incompletePositions.clear();
@@ -6181,8 +6199,9 @@
 		return;
 
 	textLayout.box()->moveTo(textLayout.box()->x(), 0);
-	double newHeight = textLayout.box()->naturalHeight();
-	newHeight += m_textDistanceMargins.bottom();
+	const double lineCorr = (lineColor() != CommonStrings::None) ? m_lineWidth / 2.0 : 0.0;
+	const double newHeight = std::ceil(qMax(textLayout.box()->naturalHeight(), maxY)
+		+ m_textDistanceMargins.bottom() + lineCorr);
 	if (qFuzzyCompare(newHeight, m_height))   // no-op guard
 		return;
 

Issue History

Date Modified Username Field Change
2025-03-13 16:12 ale New Issue
2025-03-13 16:12 ale File Added: adjust-frame-height.gif
2025-03-13 16:15 ale Relationship added related to 0014668
2025-03-13 16:15 ale Relationship added related to 0015153
2025-04-27 19:16 cbradney Category Story Editor / Text Frames => Text Frames / Story Editor
2025-10-10 14:03 JLuc Relationship added related to 0017145
2025-10-10 14:03 JLuc Relationship added related to 0016187
2026-11-04 04:22 utnik Note Added: 0054645
2026-11-04 12:46 buttar Note Added: 0054647
2026-11-04 12:46 buttar File Added: adjust-frame-height-to-text-v1.01.patch