Adobe 65009333 Scripting Guide - Page 42
Applying a font, Changing text properties, script fragment
UPC - 883919155852
View all Adobe 65009333 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 42 highlights
Text and Type Formatting text 42 Applying a font To apply a local font change to a range of text, use the appliedFont property, as shown in the following script fragment (from the ApplyFont tutorial script): //Given a font name "myFontName" and a text object "myText" myText.appliedFont = app.fonts.item(myFontName); You also can apply a font by specifying the font-family name and font style, as shown in the following script fragment: myText.appliedFont = app.fonts.item("Adobe Caslon Pro"); myText.fontStyle = "Semibold Italic"; Changing text properties Text objects in InCopy have literally dozens of properties corresponding to their formatting attributes. Even a single insertion point features properties that affect the formatting of text-up to and including properties of the paragraph containing the insertion point. The SetTextProperties tutorial script shows how to set every property of a text object. A fragment of the script follows: //Shows how to set all read/write properties of a text object. var myDocument = app.documents.add(); var myStory = myDocument.stories.item(0); myStory.contents = "x"; var myTextObject = myStory.characters.item(0); myTextObject.alignToBaseline = false; myTextObject.appliedCharacterStyle = myDocument.characterStyles.item("[None]"); myTextObject.appliedFont = app.fonts.item("Minion ProRegular"); myTextObject.appliedLanguage = app.languagesWithVendors.item("English: USA"); myTextObject.appliedNumberingList = myDocument.numberingLists.item("[Default]"); myTextObject.appliedParagraphStyle = myDocument.paragraphStyles.item("[No Paragraph Style]"); myTextObject.autoLeading = 120; myTextObject.balanceRaggedLines = BalanceLinesStyle.noBalancing; myTextObject.baselineShift = 0; myTextObject.bulletsAlignment = ListAlignment.leftAlign; myTextObject.bulletsAndNumberingListType = ListType.noList; myTextObject.bulletsCharacterStyle = myDocument.characterStyles.item("[None]"); myTextObject.bulletsTextAfter = "^t"; myTextObject.capitalization = Capitalization.normal; myTextObject.composer = "Adobe &Paragraph Composer"; myTextObject.desiredGlyphScaling = 100; myTextObject.desiredLetterSpacing = 0; myTextObject.desiredWordSpacing = 100; myTextObject.dropCapCharacters = 0; myTextObject.dropCapLines = 0; myTextObject.dropCapStyle = myDocument.characterStyles.item("[None]"); myTextObject.dropcapDetail = 0; //More text properties in the tutorial script.