Adobe 0046100128056 Scripting Guide - Page 94
Applying a font, Changing text properties
UPC - 718659087562
View all Adobe 0046100128056 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 94 highlights
CHAPTER 6: Text and Type Formatting Text 94 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 InDesign have literally dozens of properties corresponding to their formatting attributes. Even one 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 is shown below: var myDocument = app.documents.item(0); var myPage = myDocument.pages.item(0); var myTextFrame = myPage.textFrames.add(); myTextFrame.contents = "x"; var myTextObject = myTextFrame.parentStory.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; myTextObject.fillColor = myDocument.colors.item("Black"); myTextObject.fillTint = -1; myTextObject.firstLineIndent = 0; myTextObject.fontStyle = "Regular"; myTextObject.gradientFillAngle = 0; myTextObject.gradientFillLength = -1; myTextObject.gradientFillStart = [0,0]; myTextObject.gradientStrokeAngle = 0; myTextObject.gradientStrokeLength = -1;