Center text within a field?
J. Landman Gay
jacque at hyperactivesw.com
Wed Jun 6 15:07:30 CDT 2007
Trevor DeVore wrote:
> On Jun 6, 2007, at 3:43 AM, Trevor DeVore wrote:
>> I'm trying to center text in a field within a graphic (circle). The
>> text can be any font and any size.
> Update - I haven't been able to find a reliable means of calculating the
> center of text using any field properties so I resorted to exporting a
> snapshot of the field (opaque = false) to an image, grabbing the
> alphadata of the image and determining extreme left, top, right, bottom
> of the text by looping through it.
Does this work? :
set the width of fld 1 to the width of grc 1 -- the circle
get the textsize of fld 1
set the textheight of fld 1 to it + (it div 3)
set the height of fld 1 to the formattedheight of fld 1
set the margins of fld 1 to the textheight of fld 1 div 3
set the loc of fld 1 to the loc of grc 1
The field must have fixedLineHeight set to false. You might have to
jiggle the margins and textheight calcs a little bit.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode