Skip to content

style

text.sourceText.style

Most of these functions are accessible from the SourceText.style object in AE 17.0 and later. Where noted, additional methods were added in AE 25.0. The ability to control per-character styling was also added in 25.0. Use the second and third arguments (when available) to control per-character styling.

For more info on working with text styles, see:

All the methods for Text Style will return a Text Style object, so you can call them in a chain, e.g.:

text.sourceText.style.setFont("Times New Roman").setFontSize(42).setText("New Text");

text.sourceText.style.applyFill

Returns whether Fill Color is enabled.

Boolean


text.sourceText.style.applyStroke

Returns whether Stroke is enabled.

Boolean


text.sourceText.style.baselineDirection

Returns the Baseline Direction for a Text layer.

Predefined string. One of:

  • "default"
  • "rotated"
  • "tate-chuu-yoko"

text.sourceText.style.baselineOption

Returns the Baseline Option Type for a Text layer.

Predefined string. One of:

  • "default"
  • "subscript"
  • "superscript"

text.sourceText.style.baselineShift

Returns the value of Baseline Shift for a Text layer.

Number


text.sourceText.style.digitSet

Returns the Digit Set for a Text layer.

Predefined string. One of:

  • "default"
  • "hindidigits"

text.sourceText.style.direction

Returns the value of Direction of the first paragraph of a Text layer.

Predefined string. One of:

  • "left-to-right"
  • "right-to-left"

text.sourceText.style.fillColor

Returns the text Fill Color as RGB values on a scale from 0 - 1.0.

Array of Numbers.


text.sourceText.style.firstLineIndent

Returns the value of First Line Indent of the first line of the first paragraph of a Text layer.

Number


text.sourceText.style.font

Returns the font name for a Text layer.

String


text.sourceText.style.fontSize

Returns the value of Font Size for a Text layer.

Number


text.sourceText.style.horizontalScaling

Returns the Horizontal Scaling for a Text layer.

Number


text.sourceText.style.isAllCaps

Returns whether All Caps is enabled.

Boolean


text.sourceText.style.isAutoLeading

Returns whether Auto Leading is enabled.

Boolean


text.sourceText.style.isEveryLineComposer

Returns true if the Text layer if Every-Line Composer is set for the first paragraph of a Text layer and false if Single-Line Composer is set for the first paragraph of a Text layer

Boolean


text.sourceText.style.isFauxBold

Returns whether Faux Bold is enabled.

Boolean


text.sourceText.style.isFauxItalic

Returns whether Faux Italics are enabled.

Boolean


text.sourceText.style.isHangingRoman

Whether Hanging Roman Punctuation is set for the entire Text layer.

Boolean


text.sourceText.style.isLigature

Returns whether ligatures are enabled.

Boolean


text.sourceText.style.isSmallCaps

Returns whether Small Caps is enabled.

Boolean


text.sourceText.style.justification

Returns the value of Justification of the first paragraph of a Text layer.

The left and right values for alignment/justification will be reversed if the Text layer’s TextStyle.direction is set to use right-to-left. You can control this using the Property or Paragraph panel, or via TextStyle.setDirection().

Predefined string. One of:

  • "alignCenter"
  • "alignLeft"
  • "alignRight"
  • "justifyFull"
  • "justifyLastCenter"
  • "justifyLastLeft"
  • "justifyLastRight"

text.sourceText.style.kerning

Returns the Kerning Value for a Text Layer.

For this value to be returned as anything other than zero, the KerningType must not be set.

Number. Read-only.


text.sourceText.style.kerningType

Returns the Kerning Type for a Text layer.

Read-only. Predefined string. One of:

  • "manual"
  • "metrics"
  • "optical"

text.sourceText.style.leading

Returns the value of Leading for a Text layer.

Number


text.sourceText.style.leadingType

Returns the value of Leading Type for the first paragraph of a Text layer.

Predefined string. One of:

  • "bottom-to-bottom"
  • "top-to-top"

text.sourceText.style.leftMargin

Returns the value of Left Margin of the first paragraph of a Text layer.

Number


text.sourceText.style.lineJoin

Returns the Line Join Type for a Text layer.

Predefined string. One of:

  • "bevel"
  • "miter"
  • "round"

text.sourceText.style.rightMargin

Returns the value of Right Margin of the first paragraph of a Text layer.

Number


text.sourceText.style.spaceAfter

Returns the value of the Space After the first paragraph of a Text layer.

Number


text.sourceText.style.spaceBefore

Returns the value of the Space Before the first paragraph of a Text layer.

Number


text.sourceText.style.strokeColor

Returns the Stroke Color as RGB values on a scale from 0 - 1.0.

Array of numbers


text.sourceText.style.strokeWidth

Returns the Stroke Width value for a Text layer.

Number


text.sourceText.style.tracking

Returns the value of Tracking for a Text layer.

Number


text.sourceText.style.tsume

Returns the Tsume value for a Text layer.

Number (between 0 and 1).


text.sourceText.style.verticalScaling

Returns the Vertical Scaling for a Text layer.

Number


text.sourceText.style.replaceText(value[, startIndex, numOfCharacters])

This is used when you want to define (or inherit) a Text Style, while setting the content for a substring of the text.

ParameterTypeDescription
valueStringRequired.The text to set.
startIndexNumberOptional.The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional.The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.

To create a custom style and then set a substring of the text within the expression:

// assume the value of the source text is "Old Text"
const referenceText = thisComp.layer("Source Layer Name").text.sourceText;
const style = referenceText.getStyleAt(0,0);
// This will change the text from "Old Text" to "NewText" as the first 4 characters are replaced.
style.replaceText("New", 0, 4);

text.sourceText.style.setAllCaps(value[, startIndex, numOfCharacters])

Used to set the All Caps status.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable All Caps.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setApplyFill(value[, startIndex, numOfCharacters])

Used to set whether Fill Color is enabled.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable Fill.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setApplyStroke(value[, startIndex, numOfCharacters])

Used to set whether Stroke is enabled.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable Stroke.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setAutoLeading(value[, startIndex, numOfCharacters])

Used to set the Auto Leading status.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable Auto Leading.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setBaselineDirection(value[, startIndex, numOfCharacters])

Used to set the Baseline Direction.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valuePredefined string as defined in BaselineDirectionThe value to set for Baseline Direction.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setBaselineShift(value[, startIndex, numOfCharacters])

Used to set the Baseline Shift to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueNumberRequired. The Baseline Shift value to set.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setBaselineOption(value[, startIndex, numOfCharacters])

Used to set the baseline option.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valuePredefined string as defined in BaselineOptionRequired. The value to set for Baseline Option.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setDigitSet(value[, startIndex, numOfCharacters])

Used to set the Digit Set.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valuePredefined string as defined in DigitSetRequired. The value to use for Digit Set.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setDirection(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the Direction for the entire Text layer, either left-to-right or right-to-left.

ParameterTypeDescription
valuePredefined string as defined in DirectionThe desired value for Direction.

A TextStyle object.


text.sourceText.style.setEveryLineComposer(value)

This method must be called after TextStyle.setText() if both are being used.

Used to enable or disable the Every-Line Composer for the entire Text layer.

ParameterTypeDescription
valueBooleanWhether to enable or disable Every-Line Composer.

A TextStyle object.


text.sourceText.style.setFauxBold(value[, startIndex, numOfCharacters])

Used to set the Faux Bold status.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable Faux Bold.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setFauxItalic(value[, startIndex, numOfCharacters])

Used to set the Faux Italics status.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable Faux Italics.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setFillColor(value[, startIndex, numOfCharacters])

Used to set the text Fill Color.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

Keep in mind that TextStyle.applyFill must be true in order for the fill color to show up. You can set it to true by enabling Fill in the Properties or Character panel, or by using TextStyle.setApplyFill().

ParameterTypeDescription
valueArray of numbersRequired. [R, G, B] with each value between 0.0 and 1.0.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setFirstLineIndent(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the First Line Indent of a Text layer to a specified value.

ParameterTypeDescription
valueNumberThe desired value for First Line Indent.

A TextStyle object.


text.sourceText.style.setFont(value[, startIndex, numOfCharacters])

Used to set the font to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueStringRequired. The font to set.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setFontSize(value[, startIndex, numOfCharacters])

Used to set the Font Size to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueNumberRequired. The Font Size to set.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setHangingRoman(value)

This method must be called after TextStyle.setText() if both are being used.

Used to enable or disable Hanging Roman Punctuation for the entire Text layer.

ParameterTypeDescription
valueBooleanWhether to enable or disable Roman Hanging Punctuation.

A TextStyle object.


text.sourceText.style.setHorizontalScaling(value[, startIndex, numOfCharacters])

Used to set the Horizontal Scaling to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueNumberRequired. The value to set the Horizontal Scaling.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setJustification(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the Justification for the entire Text layer.

The left and right values for alignment/justification will be reversed if the Text layer’s TextStyle.direction is set to use right-to-left. You can control this using the Property or Paragraph panel, or via TextStyle.setDirection().

ParameterTypeDescription
valuePredefined string as defined in JustificationThe desired value for the Justification.

A TextStyle object.


text.sourceText.style.setKerning(value, characterIndex)

Used to set the Kerning Value at the specifed character index.

This will only affect the Text layer when KerningType is not set for the character index.

ParameterTypeDescription
valueNumberRequired. The value to set the Kerning Value.
characterIndexNumberRequired. The character index for the substring to be applied.

None


text.sourceText.style.setKerningType(value[, startIndex, numOfCharacters])

Used to set the Kerning Type.

The value will be applied to the entire Text layer unless a start index and number of characters are specified.

ParameterTypeDescription
valuemetrics or optical, as defined in KerningType.Required. The value to set for Kerning Type.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be changed. Defaults to the number of characters until end of the string.

None


text.sourceText.style.setLeading(value[, startIndex, numOfCharacters])

Used to set the Leading to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

Keep in mind that TextStyle.isAutoLeading must be false in order for setLeading() to have any visible affect. You can set Leading to a value other than Auto in the Properties or Character panel, or via TextStyle.setAutoLeading().

ParameterTypeDescription
valueNumberRequired. The Leading value to set.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setLeadingType(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the Leading Type for the entire Text layer.

ParameterTypeDescription
valuePredefined string as defined in LeadingTypeThe desired value for Leading Type.

A TextStyle object.


text.sourceText.style.setLeftMargin(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the Left Margin of a Text layer to a specified value.

ParameterTypeDescription
valueNumberThe desired value for Left Margin.

A TextStyle object.


text.sourceText.style.setLigature(value[, startIndex, numOfCharacters])

Used to enable or disable ligatures.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable ligatures.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setLineJoin(value[, startIndex, numOfCharacters])

Used to set the Line Join Type to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valuePredefined string as defined in LineJoinRequired. The value to set for Line Join Type.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setRightMargin(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the Right Margin of a Text layer to a specified value.

ParameterTypeDescription
valueNumberThe desired value for Right Margin.

A TextStyle object.


text.sourceText.style.setSmallCaps(value[, startIndex, numOfCharacters])

Used to set the Small Caps status.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueBooleanRequired. Whether to enable or disable Small Caps.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setSpaceAfter(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the Space After attribute of a Text layer to a specified value.

ParameterTypeDescription
valueNumberThe desired value for the Space After attribute.

A TextStyle object.


text.sourceText.style.setSpaceBefore(value)

This method must be called after TextStyle.setText() if both are being used.

Used to set the Space Before attribute of a Text layer to a specified value.

ParameterTypeDescription
valueNumberThe desired value for the Space Before attribute.

A TextStyle object.


text.sourceText.style.setStrokeColor(value[, startIndex, numOfCharacters])

Used to set the Stroke Color.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

Keep in mind that TextStyle.applyStroke must be true and TextStyle.strokeWidth must be greater than zero in order for any stroke color to be shown. You can set these by enabling Stroke or increasing Stroke Width in the Properties or Character panel, or by using TextStyle.setApplyStroke() and TextStyle.setStrokeWidth(), respectively.

ParameterTypeDescription
valueArray of numbersRequired. [R, G, B] with each value between 0.0 and 1.0.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setStrokeWidth(value[, startIndex, numOfCharacters])

Used to set the Stroke Width to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

Keep in mind that TextStyle.applyStroke must be true in order to see any change in stroke width. You can set this either by enabling Stroke in the Properties or Character panel, or via TextStyle.setApplyStroke().

ParameterTypeDescription
valueNumberRequired. The value to set the Stroke Width.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setText(value)

This is used when you want to define (or inherit) a Text Style while setting the text content separately.

ParameterTypeDescription
valueStringThe text to set.

A TextStyle object.

To inherit the style and content from another layer:

const referenceText = thisComp.layer("Source Layer Name").text.sourceText;
const style = referenceText.getStyleAt(0, 0);
style.setText(referenceText);

To create a custom style and then set the text within the expression:

text.sourceText
.createStyle()
.setFontSize(300)
.setFont("Impact")
.setText("Hello world!");

text.sourceText.style.setTracking(value[, startIndex, numOfCharacters])

Used to set the Tracking to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueNumberRequired. The Tracking value to set.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.


text.sourceText.style.setTsume(value[, startIndex, numOfCharacters])

Used to set the Tsume to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueNumberRequired. The value to set the Tsume, between 0 and 100.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

None


text.sourceText.style.setVerticalScaling(value[, startIndex, numOfCharacters])

Used to set the Vertical Scaling to a specified value.

The value will be set for the entire Text layer unless startIndex and numOfCharacters are specified.

ParameterTypeDescription
valueNumberRequired. The value to set the Vertical Scaling.
startIndexNumberOptional. The start index for the substring to be replaced. Defaults to 0.
numOfCharactersNumberOptional. The length of the substring to be replaced. Defaults to the number of characters until end of the string.

A TextStyle object.