Vertical Centering Text

Ivers, Doug E Doug_Ivers at lord.com
Fri Apr 11 09:07:01 EDT 2003


I'm also interested in a function that does this accurately for all possible fonts, styles, lineHeights, etc.  This seems to me to be very useful for a one line field (such as username/password entry).
I wrote one a few months ago, but it also didn't seem to work in all cases.
I suspect one of the more experienced Revolutionaries could do this in about 5 minutes.
Any takers?


On 4/9/03 6:40 PM, "Dan Friedman" <dan at clearvisiontech.com> wrote:

> Hello!
> 
> Does anyone already have a function for setting a fields topMargin so that
> it's text is centered vertically?
> 
> I got this far (don't laugh!)... Which works fine for some font sizes... But
> others are not right.
> 
> on fixLineHeight tFieldID
> put the formattedHeight of line 1 of field id tFieldID into tHeight
> put the formattedHeight of char 1 of field id tFieldID into cHeight
> put the height of field id tFieldID into fHeight
> set the topMargin of field id tFieldID to ((((fHeight - tHeight)/2) +
> (cHeight/2))-1)
> end fixLineHeight
> 
> 
> Any thoughts?
> 
> Thanks!
> Dan
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 





More information about the use-livecode mailing list