• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: width of column id name column
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: width of column id name column
      • From: Shane Stanley <email@hidden>
References: 
 >Re: width of column id name column (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: width of column id name column
  • Next by Date: Re: width of column id name column
  • Previous by thread: Re: width of column id name column
  • Next by thread: Re: width of column id name column
  • Index(es):
    • Date
    • Thread