Re: Center text within a field?
On Jun 7, 2007, at 9:34 AM, Joe Lewis Wilkins wrote: Congrats, Trevor. If you've come up with an acceptable handler that performs well, then my suggestion is entirely moot at this time. I'm surprised that you were able to come up with a good solution in the time frame you mention. Great! Oh it took me much longer to get to the point that I realized I needed to write the image analyzer :-) I spent hours trying to figure out how to solve the problem using available properties. At one point I even thought I had it working pretty well until I ran the app on Windows. -- Trevor DeVore Blue Mango Learning Systems www.bluemangolearning.com-www.screensteps.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
Congrats, Trevor. If you've come up with an acceptable handler that performs well, then my suggestion is entirely moot at this time. I'm surprised that you were able to come up with a good solution in the time frame you mention. Great! Joe Wilkins On Jun 7, 2007, at 9:24 AM, Trevor DeVore wrote: On Jun 6, 2007, at 5:09 PM, Joe Lewis Wilkins wrote: I realize it would take a lot of initial work, but you guys seem up for it: why not just use a lookup table with the exact values you need for each font "condition" listed? Hi Joe, I think the time to research all of the possible scenarios would take longer then it did to right the image analyzer handler (~1/2 hr) as I would have to do this for Mac/Win and even then I wouldn't know if it would work with fonts I don't have installed. The problem I kept running into is that different fonts at the same size can have very different heights. Of course, you can limit the amount of preparation by just limiting the acceptable fonts and perhaps some of the other ranges as well. This way the table of values could be expanded over time and by others if need be without coming up with any "exact" formulation at the outset. Just a thought! Limiting the text size ranges and fonts would have been an option and I almost went that route. But now that I have a handler to analyze the glyph I don't have to worry about it no matter what the user throws at it. Thanks, -- Trevor DeVore Blue Mango Learning Systems www.bluemangolearning.com-www.screensteps.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
On Jun 6, 2007, at 4:47 PM, J. Landman Gay wrote: So it's font dependent and we're back where we started. :( You may be stuck with your images after all, since there is no good way to read the actual positioning of the glyph inside its text box. I think I will post a feature request for getting the actual height of the glyph. That would be handy. -- Trevor DeVore Blue Mango Learning Systems www.bluemangolearning.com-www.screensteps.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
On Jun 6, 2007, at 5:09 PM, Joe Lewis Wilkins wrote: I realize it would take a lot of initial work, but you guys seem up for it: why not just use a lookup table with the exact values you need for each font "condition" listed? Hi Joe, I think the time to research all of the possible scenarios would take longer then it did to right the image analyzer handler (~1/2 hr) as I would have to do this for Mac/Win and even then I wouldn't know if it would work with fonts I don't have installed. The problem I kept running into is that different fonts at the same size can have very different heights. Of course, you can limit the amount of preparation by just limiting the acceptable fonts and perhaps some of the other ranges as well. This way the table of values could be expanded over time and by others if need be without coming up with any "exact" formulation at the outset. Just a thought! Limiting the text size ranges and fonts would have been an option and I almost went that route. But now that I have a handler to analyze the glyph I don't have to worry about it no matter what the user throws at it. Thanks, -- Trevor DeVore Blue Mango Learning Systems www.bluemangolearning.com-www.screensteps.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
On 6/6/07, J. Landman Gay <[EMAIL PROTECTED]> wrote: Joe Lewis Wilkins wrote: > I realize it would take a lot of initial work, but you guys seem up for > it: why not just use a lookup table with the exact values you need for > each font "condition" listed? Geek rule #26: It isn't cool unless you can build an algorithm to do it. ;) Geek rule #27: And coding the algorithm should take at least as long as any brute force mechanism would. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
Joe Lewis Wilkins wrote: I realize it would take a lot of initial work, but you guys seem up for it: why not just use a lookup table with the exact values you need for each font "condition" listed? Geek rule #26: It isn't cool unless you can build an algorithm to do it. ;) -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
I realize it would take a lot of initial work, but you guys seem up for it: why not just use a lookup table with the exact values you need for each font "condition" listed? Of course, you can limit the amount of preparation by just limiting the acceptable fonts and perhaps some of the other ranges as well. This way the table of values could be expanded over time and by others if need be without coming up with any "exact" formulation at the outset. Just a thought! Joe Wilkins On Jun 6, 2007, at 4:47 PM, J. Landman Gay wrote: Trevor DeVore wrote: On Jun 6, 2007, at 4:01 PM, J. Landman Gay wrote: 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. This one works for webdings for me as well. I tried it with Arial (on Mac), textsize set to 48 and the "1" drifted towards the top of the circle. Does Arial work on your machine? Pretty close to center, but yeah, it drifts up a bit. What the handler needs is a math calculation. I stuck in the "if" clause because very small fonts got clipped at the top without adding some overhead, whereas larger sizes shouldn't have any additional textheight at all. So the math would ideally calculate a variable textheight based on the text size. Small sizes would get extra textheight and large sizes would get less. For example, the Ariel 48 text works if the textheight is 55, so the textheight needs to be calculated by multiplying the text size times about 1.15. For 12-point, a textheight of about 20 seems right. For 100 point, textheight (using Ariel) requires about 135. But for Webdings, 100 point text needs 100 textheight. So it's font dependent and we're back where we started. :( You may be stuck with your images after all, since there is no good way to read the actual positioning of the glyph inside its text box. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
Trevor DeVore wrote: On Jun 6, 2007, at 4:01 PM, J. Landman Gay wrote: 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. This one works for webdings for me as well. I tried it with Arial (on Mac), textsize set to 48 and the "1" drifted towards the top of the circle. Does Arial work on your machine? Pretty close to center, but yeah, it drifts up a bit. What the handler needs is a math calculation. I stuck in the "if" clause because very small fonts got clipped at the top without adding some overhead, whereas larger sizes shouldn't have any additional textheight at all. So the math would ideally calculate a variable textheight based on the text size. Small sizes would get extra textheight and large sizes would get less. For example, the Ariel 48 text works if the textheight is 55, so the textheight needs to be calculated by multiplying the text size times about 1.15. For 12-point, a textheight of about 20 seems right. For 100 point, textheight (using Ariel) requires about 135. But for Webdings, 100 point text needs 100 textheight. So it's font dependent and we're back where we started. :( You may be stuck with your images after all, since there is no good way to read the actual positioning of the glyph inside its text box. -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
On Jun 6, 2007, at 4:01 PM, J. Landman Gay wrote: 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. This one works for webdings for me as well. I tried it with Arial (on Mac), textsize set to 48 and the "1" drifted towards the top of the circle. Does Arial work on your machine? -- Trevor DeVore Blue Mango Learning Systems www.bluemangolearning.com-www.screensteps.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
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 | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
On Jun 6, 2007, at 1:07 PM, J. Landman Gay wrote: Does this work? : on mouseUp 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 end mouseUp The field must have fixedLineHeight set to false. You might have to jiggle the margins and textheight calcs a little bit. 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. While webdings isn't a font that will be used in what I'm doing it does illustrate the problem nicely. The textsize of a char does not return the actual vertical space taken up by the char so it makes it difficult to find the exact center of text that is being displayed. -- Trevor DeVore Blue Mango Learning Systems www.bluemangolearning.com-www.screensteps.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
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? : on mouseUp 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 end mouseUp The field must have fixedLineHeight set to false. You might have to jiggle the margins and textheight calcs a little bit. -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: Center text within a field?
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. I've included the function for anyone who is interested in taking a look. It seems to be working but I'm severely sleep deprived right now so who knows :-) This function is part of a group script that has one field and one invisible image. function FindCenterOfText local theAlphaData,theByte,theColumnCount,theColumnNo local theOpaque,theRect,theRowNo local theValue lock screen put the opaque of field 1 of me into theOpaque set the opaque of field 1 of me to false ## CREATE IMAGE WITH ALPHADATA export snapshot from field 1 of me to image 1 of me as PNG put the alphadata of image 1 of me into theAlphaData set the text of image 1 of me to empty ## DEFINE OUR GRID put the width of image 1 of me into theColumnCount ## LOOP THROUGH ALPHA DATA LOOKING FOR PIXELS THAT MEET THE VISIBILITY THRESHOLD put 1 into theRowNo put 0 into theColumnNo put 0,0,0,0 into theRect repeat for each char theByte in theAlphaData add 1 to theColumnNo put chartonum(theByte) into theValue if theValue > 100 then if item 1 of theRect is 0 then put theColumnNo into item 1 of theRect put theRowNo into item 2 of theRect put theColumnNo into item 3 of theRect put theRowNo into item 4 of theRect end IF put min(theColumnNo, item 1 of theRect) into item 1 of theRect put min(theRowNo, item 2 of theRect) into item 2 of theRect put max(theColumnNo, item 3 of theRect) into item 3 of theRect put max(theRowNo, item 4 of theRect) into item 4 of theRect end if if theColumnNo is theColumnCount then add 1 to theRowNo put 0 into theColumnNo end if end repeat set the opaque of field 1 of me to theOpaque unlock screen put item 1 of theRect + (item 3 of theRect - item 1 of theRect) / 2 into item 1 of theLoc put item 2 of theRect + (item 4 of theRect - item 2 of theRect) / 2 into item 2 of theLoc ## YEAH, THIS IS FOR GETTING THE FLOOR replace comma with cr in theLoc set the itemdelimiter to "." delete item 2 of line 1 of theLoc delete item 2 of line 2 of theLoc replace cr with comma in theLoc set the itemdelimiter to comma add the left of field 1 of me to item 1 of theLoc add the top of field 1 of me to item 2 of theLoc return theLoc end FindCenterOfText -- Trevor DeVore Blue Mango Learning Systems www.bluemangolearning.com-www.screensteps.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution