Mantis Issue Tracking for Scribus
· Hosting provided by / Øverby Consulting ·

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012154ScribusStory Editor / Text Framespublic2014-03-22 16:482015-11-24 10:14
Assigned To 
Platformx86_64OSopenSUSEOS Version13.1
Product Version1.5.0svn 
Target Version1.5.1Fixed in Version 
Summary0012154: "Adjust Frame Height to Text" inconsistent behaviour with Middle/Bottom Vertical Alignment
DescriptionAdjust Frame Height to Text is inconsistent when Middle or Bottom Vertical Alignment is selected.
Steps To Reproduce0) Create a new document
1) Insert a Text Frame (higher is better)
2) Write one word
3) Properties > Text > Columns & Text Distances > Vertical Alignment > Middle or Bottom
4) Select the Text Frame > Right-click > Adjust Frame Height to Text

The behaviour of Scribus is not useful for users who select "Adjust Frame Height to Text". Scribus should adjust the height as with "Top" selected or change both the height over and under the text so that the text keeps its position.
Additional InformationScribus 1.5.0 SVN (18929) - Qt 5.2.1
TagsHOST-Oman, patch_tested_ok
Attached Files? file icon auto-height-and-margins.sla [^] (14,199 bytes) 2015-11-09 07:24
png file icon autoheight-and-margins.png [^] (33,256 bytes) 2015-11-09 07:24

diff file icon AdjustHeightToText.diff [^] (2,545 bytes) 2015-11-10 07:29 [Show Content]

- Relationships
related to 0011613newcbradney [PATCH] vertical position of line depending on text (same content, different layout) 

-  Notes
Kunda (manager)
2014-06-15 15:06

Agreed. Reproduced on r19232 (OS X 10.8.5 with Homebrew packaged Qt5)
ibrahim (reporter)
2015-11-08 08:53

The function m_textDistanceMargins.bottom() in the function setTextFrameHeight always returns zero. do you think that this is the problem?
ibrahim (reporter)
2015-11-08 11:51

Please correct me if I am wrong..

I understand from the problem that we need a way to get the distance from the top of the text frame to the first line written on it . do you have idea how to do it.
ale (manager)
2015-11-09 07:22

i did not have a look at the code, but i've now attached .sla where you can play around and see how the vertical alignment works.

you should then open the properties palette at the "text > columns and distances" tab.

you will see that you can define a top and bottom margin and still change the value for the vertical alignment.

back to the auto-height feature.

you should have a look at it and understand what values it changes when you trigger it.

looking at the name of the method, i'm not sure that m_textDistanceMargins.bottom() is the function you're looking for.
ibrahim (reporter)
2015-11-10 07:28

Thanks, now I am understand the different between the distance margin and vertical alignment. I searched on the code and I found that the function setTextFrameHeight is responsible of the option "Adjust Height to Text" so I modified it and I ended up with the attached patch.

Please can you look at it.
ibrahim (reporter)
2015-11-17 08:20

The idea of this patch is to use the function setHeight to determine the height of the text frame.

The setHeight function works by receiving the sum of 3 variables :
1)The ceiling of variable called maxY which has the height need to be set.
2)The m_textDistanceMargins.bottom() variable which represent the distance between the margin and the text frame.
3)hackValue which was set as 0.5.

So, I modified the maxY to be only the frame height. I used to do that the following formula:
LH= height of line
LN= number of lines
LS= space between each two lines

maxY = LH * LN + (LN-LN/2)/2

The height of each line I get it from subtract two variables(regionMinY and regionMaxY)
JLuc (developer)
2015-11-21 19:50

Ibrahim :
Is your patch OK aswell for bottom aligned text ?
Have you tested the altered functions in other text layout situations ?
gpittman (developer)
2015-11-21 22:25

I have a hard time understanding what the expected or desired behavior is. (and why)
Perhaps Adjust Frame Height to Text should be disabled whenever Middle or Bottom is chosen for the position of the text.
JLuc (developer)
2015-11-21 23:12
edited on: 2015-11-21 23:13

I think there is a desired behaviour : have the frame fit the text. It's possible to want this, whatever vertical align is set.

AMOF as for now, "fit to text" brings the end of the frame to the bottom Y of the text. That is Ok for top aligned text, but not ok for center or bottom verticaly aligned text :
- As for now, when vertical align is bottom, "fit to text" does nothing.
- And when vertical align is center, "fit to text" makes the text height smaller, but not fit text height.

Note to Ibrahim : For bottom aligned text, 'fit to text' should bring the *top* Y of the frame to the *top* of the text, and not change the bottom Y (of both text and frame).

gpittman (developer)
2015-11-22 02:03

Here are 2 solutions, which do not involve and patches:

1. Click Undo BEFORE choosing Adjust Frame Height to Text

2. Select for text to align to Top instead of middle. THEN choose Adjust Frame Height to Text.

Let's face it, when you choose Align to middle, then want to shrink the frame, YOU HAVE MADE A MISTAKE. IT'S NOT THE SOFTWARE'S FAULT YOU HAVE MADE A MISTAKE.
gpittman (developer)
2015-11-22 02:08

Is this a bug?

I put some text in a frame. I select Adjust Frame Height to Text.

I add more text -- now the text overflows! Even if I select Adjust Frame Height to Text again, it still doesn't enlarge the frame!
JLuc (developer)
2015-11-22 09:46
edited on: 2015-11-22 09:46

Greg : please create a new report for other issues.

In comment to your [^] comment :

You suggest to "undo". I guess when you suggest to undo, it is because your last action was to "vertical align to middle". This might be your case when testing this issue, but this is not the general case. In the general case, the user has "aligned to middle" (or to bottom) at some point in the DTP process, and later, maybe much later, the user sees that a better layout is to "adjust frame to height".

It is not the software fault, and it is not a fault at all : it is a legit wish, part of a living design process that we can not discuss.

The "adjust frame to height" exists. Its action should fit the clear intent that is expressed in its clear label : "adjust frame to height".
It should deliver what it promises. And since it is possible to "adjust frame to height" without moving text, even when text is bottom or center aligned, it should not move the text.

gpittman (developer)
2015-11-22 15:34

This is an unimportant bug. One of the most important features of Scribus to learn is how to Undo, once or serially. Undo helps us learn what not to do, and how our workflow is broken.

My suggestion would be either of these:

1. Disabling Adjust Frame Height to Text when Align to Middle or Bottom is selected

2. Automatically switch to Align to Top when Adjust Frame Height to Text is selected
JLuc (developer)
2015-11-22 23:24

Greg : Undo is not related to this issue and is not a solution to this issue.

Greg : I understand your proposals about this issue, but that looks like a low profile solution.

I think that fixing the issue with the original intent is better, all the more since its very close to be done properly.
According to Ibrahim, his patch fixes the action when text is aligned to center.

And fixing the action when text is aligned to bottom seems simpler, since what has is to be done is :
- ensuring to not change the bottom Y of frame, so that the text doesnt move when the frame's height is changed.
- change frame's height so as to bring the top Y of frame to the top Y of text beginning.

AMOF, this action when text is bottom aligned is exactly symetrical to what it is when text is top aligned. (When text is top aligned, top Y is not changed, but bottom Y is brought to the bottom Y of the end of text).

Ibrahim : Can you try to achieve this ?
gpittman (developer)
2015-11-23 03:46

The patch doesn't seem to break anything.

One thing to note is that you do not end up with the same result with Top, Middle, and Bottom alignment, as far as precisely where the line of text is in the frame. Is this what users will want and/or expect?

Also (and maybe the same issue?), with Top alignment, the end result is slightly narrower than when using Middle or Bottom alignment.
For example, with 12 pt text and Top, I get a frame height of 18.50 pt, while with Middle and Bottom alignment, I get 21.50 pt frame height. So it seems that maybe your calculations are still a bit off.

As far as JLuc's contentions about trying to keep the text from moving on the page, I don't know if that's what users collectively want or not ...
ibrahim (reporter)
2015-11-23 08:37

Regard to your comment gpittman [^]

1. I agree with Jloc that undo will not do any thing to solve this behaviour
2. The peace of code responsable of butting the text up , bottom and down is located in the function layout in pageitem_textframe.cpp . From the code you can recognize that it always up.
JLuc (developer)
2015-11-23 11:26

ibrahim : i dont understand "From the code you can recognize that it always up." what does mean "it allways up" ?
JLuc (developer)
2015-11-23 12:44

ok i understand what you mean with "it allways up" after testing your patch.

So you have choosen to keep Y of frame, and as a consequence, the text moves.

IMO It's not the smartest solution, but its better than what we have now.

The result for bottom, center and top aligned text is not exactly the same, as Greg says, but that's probably because of how scribus deals with line's height, depending or not on the the glyphs in the text with high ascending or low descending parts. There are other reports about this. I'm afraid this is much more complex an issue and not tackled in this report.

So i mark this patch as tested ok.
gpittman (developer)
2015-11-23 14:57

I don't think we can mark this as fixed or resolved. It is considerably better, but this variable behavior depending on the vertical alignment will be confusing to users.
It might be worth committing this just because it's so much better than previously, but perhaps this can be further tweaked.
gpittman (developer)
2015-11-24 01:19

Here is somewhere else where the patch produces problems.

I made a script some time ago to center text vertically in the frame. It does this by taking information about the lines of text, then adjusting the Top Distance.
I could run this, then use Adjust Frame Height to Text, and the bottom of the frame would be just below the text. The patch ignores any Top Distance, and makes the frame too small - text overflows.

To show this yourself, make a frame, put in a line of text, then adjust the Top Distance so that your text is about in the middle of the frame. Now select Adjust Frame Height to Text. Your frame will be too small to show the text.

So this patch isn't looking so good at this point.
JLuc (developer)
2015-11-24 10:13
edited on: 2015-11-24 10:14

I'm glad we agree on considering this patch as OK as is.

As for the future improvement, i'm not sure, but it could be that the precise height of resized frame issue is not specifically related to "adjust frame height to text" but to a more general issue in scribus. See some reports that mention this type of issue :
- 0011613 : Vertical position of line depending on text (same content, different layout) with cz patch provided, waiting to be tested and merged !
- 0012190 : Incorrect text align in textbox (final line).
- 0012138 : Bottom align : text disappear when frame is too high

- Issue History
Date Modified Username Field Change
2014-03-22 16:48 FirasH New Issue
2014-06-15 15:06 Kunda Note Added: 0032174
2014-07-06 18:06 FirasH Status new => confirmed
2014-08-21 13:56 Kunda Target Version => 1.5.1
2015-09-17 22:08 Kunda Category Story Editor / Text Frames => Story Ed/Txt Frames
2015-09-17 22:12 Kunda Category Story Ed/Txt Frames => Story Editor / Text Frames
2015-11-03 06:20 ibrahim Tag Attached: HOST-Oman
2015-11-08 08:53 ibrahim Note Added: 0037311
2015-11-08 11:43 ibrahim Note View State: 0037311: private
2015-11-08 11:51 ibrahim Note Added: 0037316
2015-11-09 07:22 ale Note Added: 0037329
2015-11-09 07:24 ale File Added: auto-height-and-margins.sla
2015-11-09 07:24 ale File Added: autoheight-and-margins.png
2015-11-10 07:28 ibrahim Note Added: 0037369
2015-11-10 07:29 ibrahim File Added: AdjustHeightToText.diff
2015-11-10 09:08 JLuc Note View State: 0037311: public
2015-11-14 15:33 ibrahim Note Added: 0037484
2015-11-17 06:23 ibrahim Note Deleted: 0037484
2015-11-17 08:20 ibrahim Note Added: 0037522
2015-11-21 19:50 JLuc Note Added: 0037576
2015-11-21 22:25 gpittman Note Added: 0037578
2015-11-21 23:12 JLuc Note Added: 0037579
2015-11-21 23:13 JLuc Note Edited: 0037579 View Revisions
2015-11-22 02:03 gpittman Note Added: 0037583
2015-11-22 02:08 gpittman Note Added: 0037584
2015-11-22 09:46 JLuc Note Added: 0037588
2015-11-22 09:46 JLuc Note Edited: 0037588 View Revisions
2015-11-22 15:34 gpittman Note Added: 0037589
2015-11-22 23:24 JLuc Note Added: 0037592
2015-11-23 03:46 gpittman Note Added: 0037595
2015-11-23 08:37 ibrahim Note Added: 0037596
2015-11-23 11:26 JLuc Note Added: 0037599
2015-11-23 12:44 JLuc Note Added: 0037601
2015-11-23 12:45 JLuc Tag Attached: patch_tested_ok
2015-11-23 14:57 gpittman Note Added: 0037607
2015-11-24 01:19 gpittman Note Added: 0037621
2015-11-24 10:13 JLuc Note Added: 0037636
2015-11-24 10:13 JLuc Relationship added related to 0011613
2015-11-24 10:14 JLuc Note Edited: 0037636 View Revisions

Copyright © 2000 - 2015 MantisBT Team
Powered by Mantis Bugtracker