What is the applescript to align the right side of a text immediately to the left of a certain point? Here is what I'm using:
This aligns the text correctly in some cases, but if I change the overall scaling, the text drifts to the right or to the left of the alignment point. What I need is a positive way to stick the rightmost character of the text a certain distance to the left of a certain point. I speculate that my problem is related to the “size: {20, 10}”, which establishes the width of the text box (independent of the actual width of the text). However, if I leave this out, I get no text at all (perhaps it defaults to 0,0). I think that what is happening is that as my scale changes, the width of the text box changes, but the text size (determined by the pointsize) does not; this inconsistency causes the drift. If this is correct, then if I had a way to go from a certain text string (and font and pointsize) to the exact width of the text block in points, then the rightmost character of the text would always be in the same relation to the right side of the text box, and so it would also be in the right place relative to the point I want to align it to.
Any suggestions?
UPDATE: OK, I'm having a bit better luck using “autosizing:full” and “size:{1, 1}”. This makes the text rectangle fit the text correctly. But I'm still having a problem placing the R.H. side of the text to the left of a certain point.
UPDATE 2: Well, I've worked around the problem by space-padding my text labels and using Menlo-Regular (monospaced) as the font, then just setting the origin of the text a known difference to the left of the reference point. But I'd still like to know the right way to do this, if there is one. Something akin to origin:{x, y} but where “origin” could be (e.g.) N, NE, E, SE, S, SW, W, NW, or C, instead of being limited to just NW as it is now.
Code:
make new shape at front of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: clip, size: {20, 10}, text: {text: "***", size: 14, alignment: right, font: "Helvetica", text: "***"}, origin: {5.85714285714285714, -51}, vertical padding: 0}
Any suggestions?
UPDATE: OK, I'm having a bit better luck using “autosizing:full” and “size:{1, 1}”. This makes the text rectangle fit the text correctly. But I'm still having a problem placing the R.H. side of the text to the left of a certain point.
UPDATE 2: Well, I've worked around the problem by space-padding my text labels and using Menlo-Regular (monospaced) as the font, then just setting the origin of the text a known difference to the left of the reference point. But I'd still like to know the right way to do this, if there is one. Something akin to origin:{x, y} but where “origin” could be (e.g.) N, NE, E, SE, S, SW, W, NW, or C, instead of being limited to just NW as it is now.
Last edited by gshenaut; 2013-03-03 at 03:26 PM..