Center text within a field?

J. Landman Gay jacque at hyperactivesw.com
Wed Jun 6 19:01:51 EDT 2007


Trevor DeVore wrote:

> Unfortunately it won't work in all cases. Using a field with the text 
> set to "1" and the textfont set to "webdings" is a good test case. The 
> problem is that even though you may have the textsize set to 100, the 
> vertical space taken up by the character is only 70 pixels (on my Mac). 
> Other characters in the font might take up more or less vertical space.

Version 2:

on mouseUp
   set the width of fld 1 to the width of grc 1
   get the textsize of fld 1
   if it < 20 then add 5 to it
   set the textheight of fld 1 to it
   set the height of fld 1 to it
   set the loc of fld 1 to the loc of grc 1
end mouseUp

For this one, set the fixedLineHeight of the field to true, and the 
margins to 0. (It also depends on the font and size of the field rather 
than individual textchunks.)

It seems to work with the webdings example and a few others I tried up 
to a textsize around 100. More than that and it starts to drift 
downward, depending on the font. If the above isn't suitable I guess 
your image solution is the way to go.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list