Porting text and text style from one layer to another via expressions
I'm using a "raw" text layer to hold user-entered text, then splitting it by line into "display" layers ("line1" and "line2"). They are basically parsed and stylized versions of the raw. However the text isn't consistently showing correctly on screen, if at all.
For example, the following expression in the "line1" layer's sourceText property produces NO text on screen at all:
// Establish base variables
rawText = thisComp.layer("TEXT_RAW").text.sourceText;
layerName = thisLayer.name
lineNum = Number(layerName.charAt(layerName.length-1));
lineIndex = lineNum-1;
// Set the display text for this layer
displayText = rawText.split("\r")[lineIndex];
// Copy font and styling info from Raw Text layer
fontName = rawText.style.font
fontSizeValue =rawText.style.fontSize;
fauxBoldValue = rawText.style.isFauxBold;
fauxItalicValue = rawText.style.isFauxItalic;
allCapsValue = rawText.style.isAllCaps;
smallCapsValue = rawText.style.isSmallCaps;
// Copy any additional attributes that are not customizable by default interface.
strokeWidthValue = thisComp.layer("vars").effect("strokeWidth")("Slider");
strokeColorValue = thisComp.layer("vars").effect("strokeColor")("Color");
fillColorValue = thisComp.layer("vars").effect("baseColor")("Color");
// Access this text layers style object
textStyle = thisLayer.text.sourceText.style
// Apple text styles
textStyle.setText(displayText);
textStyle.setFont(fontName);
textStyle.setFontSize(fontSizeValue);
textStyle.setFillColor(fillColorValue);
textStyle.setFauxBold(fauxBoldValue);
textStyle.setFauxItalic(fauxItalicValue);
textStyle.setAllCaps(allCapsValue);
textStyle.setSmallCaps(smallCapsValue);
textStyle.setStrokeWidth(strokeWidthValue);
textStyle.setStrokeColor(strokeColorValue);
Swapping out that last block, "Apply text styles" for a one-liner equivalent DOES produce text on screen. However even in this case the stroke is not applied, color or width. Any ideas?
// Apple text styles
textStyle.setText(displayText).setFont(fontName).setFontSize(fontSizeValue).setFillColor(fillColorValue).setFauxBold(fauxBoldValue).setFauxItalic(fauxItalicValue).setAllCaps(allCapsValue).setSmallCaps(smallCapsValue).setStrokeWidth(strokeWidthValue).setStrokeColor(strokeColorValue)
