Vertically aligning text in a field
J. Landman Gay
jacque at hyperactivesw.com
Sat Dec 20 14:24:44 EST 2014
On 12/20/2014, 1:18 PM, J. Landman Gay wrote:
> I found that by adding a small number of pixels to the top margin I
> could get it close, which is what Bernd was doing too. I've been trying
> to figure out where the problem is, but like him, I don't see anything
> offhand. I'm pretty sure the engine must either be adding padding to the
> top line, or else not reporting the underhang of the last line, which
> makes the formattedWhatever functions not quite exact.
On the theory that the problem isn't at the top but rather at the
bottom, I calculated the amount of space occupied by the (imaginary)
line 0 in the field. I think in general 2/3 of the text is placed above
the baseline and 1/3 of it is placed below that. So the top line would
be offset by 1/3 the textheight of the (nonexistent) line 0.
This seems to come closer to what we want:
put round(the effective textheight of fld 1 * .66) into tUnderHang
set the topmargin of fld 1 to (the height of fld 1 - (the
formattedheight of line 1 to -1 of fld 1) + tUnderHang) div 2
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list