This content has been marked as final. Show 6 replies
Generally speaking, they'll give the same result, but there are circumstances where that is not true.
endBaseline is the baseline of the last character of the referenced text.
baseline is the baseline of the first character of the referenced text.
Sadly, it is very difficult to calculate the effective baseline of a line of text. That is, the baseline that determines whether or not a line of text will fit within a text frame. This is because subscripts give a shifted baseline, but they do not push text to the next frame if the line is hard up against the bottom of the frame.
I gave up trying to come up with the definitive solution when I was writing a script to handle these kinds of things. I actually forgot about the endBaseline feature and went for:
I believe this gives the same result as:
Of course, this all changes if the text frame is rotated.
Thank you, Dave. As always, you are a great help.
> Sadly, it is very difficult to calculate the effective baseline of a line of text. That is, the baseline that determines whether or not a line of text will fit within a text frame.
I totally agree. I've noticed this, too. I've fiddled around with getting the baseline of every character 'myLine.characters.everyItem().baseline', but as you pointed out, those numbers won't necessarily indicate whether the character is baseline shifted or subscripted, both of which will fall below the bottom of a frame.
Baseline shifted is easy to deal with because you can get at that value but subscript isn't.
> 'the baseline that determines whether or not a line of text will fit within a text frame'.
Subscript (and baseline shift) in a line doesn't effect whether text will fit in a frame, it will just fall below the frame, so that shouldn't effect whether the line fits or not.
>'Baseline shifted is easy to deal with because you can get at that value but subscript isn't.'
Not sure exactly what you mean, but you can get the baseline of a subscript character the same way you get the baseline of any other character, as far as I can tell (CS3). If you do 'myCharacter.baseline' on a subscripted character it will return the baseline of the subscripted character.
Otherwise, if you are just trying to determine the lowest baseline that will effect whether the line fits in a frame then it seems, on first glance, all you need to do is to compare the array of results returned by 'myLine.characters.everyItem().baselineShift' and the array of results returned by 'myLine.characters.everyItem().position'. The baseline value for the first character in the line with 0 value for baselineShift and in 'normal' position is the highest point you can have your frame before the line will spill into the next frame/column. (I imagine you could even shortcut this by using text style ranges on the line instead of looking at every character.)
Now that I've rambled on, I realise I'm probably missing the point of your original problem, so never mind. (And I haven't fully investigated OTF subscript and OTF denominator.)
The point is if you are trying to fit a text frame to its contents exactly as would happen if you did fit Frame to Contents on the last frame of a story.
A subscripted character gives you the wrong value. This is important if you're working with a threaded story and you're trying to do things like align the bottom of a two-column frame with the top of a following single-column frame in such a way that the text lines up correctly on the page according to the vertical spacing of the paragraphs.
Granted, a subscript will only introduce a small error, but it will nonetheless be an error.
> The point is if you are trying to fit a text frame to its contents exactly as would happen if you did fit Frame to Contents on the last frame of a story.
No problems, I fully understand. The objective I described is the solution: you need to find a normal character in the line that is not shifted in any way and use that character's baseline value.
> Granted, a subscript will only introduce a small error, but it will nonetheless be an error.
I agree, but only in the circumstance where you use the baseline value of the shifted character instead of a 'normal' character in the line.
I think for the most part we are saying the same thing with regards to how this conversation started. If you get 'myTextFrame.lines[-1].baseline', it actually returns the baseline of the first character in the line. If that character is subscripted, superscripted or otherwise baseline shifted, then the result will not be the exact baseline you are after.
I have a script which fits story frames (like Fit Frame to Contents) and I use the following handler to ensure I've got a character in the line which is not baseline shifted in any way. One thing to watch out for, however, is when
character in the line is shifted in some way, then the handler will fall back to returning the value of the lowest baseline for the line, to ensure the returned value doesn't make the frame breaks change:
] app.findTextPreferences = NothingEnum.nothing;
app.findTextPreferences.position = 1852797549;
app.findTextPreferences.baselineShift = 0;
var myNormalCharacters = theLine.findText();
if (myNormalCharacters.length != 0)
]] return myNormalCharacters.baseline;
]] var myBaselines = theLine.insertionPoints.everyItem().baseline;
]] return myBaselines[myBaselines.length - 1];