• 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: InDesign CS4 Fractions Script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: InDesign CS4 Fractions Script


  • Subject: Re: InDesign CS4 Fractions Script
  • From: Stan Cleveland <email@hidden>
  • Date: Tue, 21 Sep 2010 14:34:10 -0700

On Sep 21, 2010, at 12:10 PM, Simon, Garry wrote:

Hi, is anyone aware of an existing script that will make proper fractions in an InDesign CS4 document? That is, converts type from a format of numbers separated by a slash into what looks more like a proper fraction. I have a script that works for CS2 which relies heavily on InDesign's "search/replace" ability, but it doesn't work for CS4. There are commercial products out there such as "ProperFraction", but was hoping to solve the problem with a simple script.

Hi Garry,

The following code should do the job. You may need to tweak the kerning values for different fonts. You will also need to set the usingFractionSlash variable to false, if the font you're using doesn't contain the fraction slash character.

HTH,
Stan C.

-- before running script, select all characters of fraction (and nothing else)
-- script looks for a forward slash, not a fraction slash, in the selection 
set usingFractionSlash to true -- if false, keeps regular forward slash
set fractionSlash to character id 8260 -- not all fonts have this character
tell application "Adobe InDesign CS4"
tell (selection)
set {txt, sz} to {contents, point size}
if (count of characters of txt) < 3 then
error "Selection is too small for a fraction."
else if txt does not contain "/" then
error "Selection does not contain a slash."
end if
set x to offset of "/" in txt
-- adjust slash and spacing
if usingFractionSlash then
set character x to fractionSlash
set kerning value of character (x - 1) to -60.0
set kerning value of character x to -60.0
else
set kerning value of character (x - 1) to -100
set kerning value of character x to -80.0
end if
-- adjust numerator
tell characters 1 thru (x - 1)
set point size to sz * 0.55
set baseline shift to sz * 0.3
end tell
-- adjust denominator
tell characters (x + 1) thru -1
set point size to sz * 0.55
end tell
end tell
end tell

 _______________________________________________
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

References: 
 >InDesign CS4 Fractions Script (From: "Simon, Garry" <email@hidden>)

  • Prev by Date: Setting Data Source for Microsoft Word mail merge
  • Next by Date: Let's Try Again - InDesign CS4 Script to Make Fractions
  • Previous by thread: InDesign CS4 Fractions Script
  • Next by thread: GUI Scripting helper
  • Index(es):
    • Date
    • Thread