• 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: 3 random typefaces intermixed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 3 random typefaces intermixed


  • Subject: Re: 3 random typefaces intermixed
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 27 Mar 2008 18:29:36 -0400

Well, this works:

set fontList to ["TimesNewRomanPSMT", "Tahoma", "LucidaHandwriting-Italic"]
set text item delimiters to ""

tell application "TextEdit"
	set c to get count of characters of text of document 1
	repeat with i from 1 to c
		set fontIndex to random number from 1 to 3
		set fontChoice to item fontIndex of fontList
		set font of character i of text of document 1 to fontChoice
	end repeat
end tell

But it is, as Doug said, dog slow.  In fact, just

repeat with i from 1 to c
-- do nothing
end repeat

takes forever inside a TextEdit tell block.  Looping outside TextEdit
is fast, but adding the tell inside the loop brings the slowness right
back.

TextEdit supports the idea of "attribute runs"; I can imagine that if
instead of setting the font on each individual character, you first
decided (randomly) how many in a row to set and did them all in one
go, it might help a little, but I couldn't figure out how to make a
new attribute run of a certain size out of existing text.
 _______________________________________________
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: 3 random typefaces intermixed
      • From: Michelle Steiner <email@hidden>
    • Re: 3 random typefaces intermixed
      • From: deivy petrescu <email@hidden>
References: 
 >Re: 3 random typefaces intermixed (From: Doug <email@hidden>)

  • Prev by Date: Re: 3 random typefaces intermixed
  • Next by Date: Re: 3 random typefaces intermixed
  • Previous by thread: Re: 3 random typefaces intermixed
  • Next by thread: Re: 3 random typefaces intermixed
  • Index(es):
    • Date
    • Thread