Re: width of column id name column
Re: width of column id name column
- Subject: Re: width of column id name column
- From: Shane Stanley <email@hidden>
- Date: Thu, 23 Jun 2011 15:35:13 +1000
- Thread-topic: width of column id name column
Title: Re: width of column id name column
On 23/6/11 2:55 PM, "Christopher Stone" <email@hidden> wrote:
> I did some looking on the net, and it seems that TCL might have some functions
> to measure string width in a give font.
Why not use AppleScript, with a bit of help:
set theString to "How long is a piece of string?"
-- get the right(?) font and size; change to suit
set theFont to current application's NSFont's systemFontOfSize_(current application's NSFont's smallSystemFontSize())
-- build a string attributes dictionary using just the font
set attrsDict to current application's NSDictionary's dictionaryWithObject_forKey_(theFont, current application's NSFontAttributeName)
-- make string an NSString
set theString to current application's NSString's stringWithString_(theString)
-- get its size
set theRect to theString's sizeWithAttributes_(attrsDict)
-- extract the width (in points)
set theWidth to width of (theRect as record)
--> 157.20654296875
--
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden