HOW TO SET DIFFERENT STYLES FOR MULTIPLE LINES
Copy link to clipboard
Copied
How can I set different styles for multiple lines. If i have two line, i need to set different styles for both the lines on the same layer
Copy link to clipboard
Copied
What do you specifically mean by "style"? Expressions? Layer Styles? Basic text formattting? Something else? You need to clarify and explain better.
Mylenium
Copy link to clipboard
Copied
Style in terms of color, font of the text. I have a double line in the same layer. I want to apply a different font, size and color to first line and then apply a different font, size color to the second line. I want to achieve this using expressions.
Copy link to clipboard
Copied
I have tried the below, but this doesn't seem to work
display = splits[0] + “\r”;
b = thisComp.layer(“Test”).text.sourceText.getStyleAt(0); // getting style from another layer
style = b;
style.setText(display); // applying style to the display variable which contains some text
finals = display + splits[1]; // adding text to the second line
finals // applying the final text to this text layer.
Copy link to clipboard
Copied
Well, unless "splits" is defined as a function somewhere, this of course cannot work. You code does contain exactly zero actual string processing.
Mylenium
Copy link to clipboard
Copied
I have tried the below also without splits still it doesn't work:
display = "this is amazing";
b = thisComp.layer("Test").text.sourceText.getStyleAt(0);
style = b;
style.setText(display) + "sometext";
but on the last line if i remove +"sometext"; then it works such as :
style.setText(display)
In general it doesn't allow to add something once you apply the style.
Is there any other way of doing, apply different styles to different lines
Copy link to clipboard
Copied
Again, your code simply doesn't do anything because there is no real string processing and you're completely misunderstanding how those functions work. You might want to actually read the online help and also how strings are handled in JavaScript on a general level.
Mylenium
Copy link to clipboard
Copied
Just to clarify the splits was defined as follows, i had omitted it just to show the code that was required
splits = textie.split("**");
The target is if the text comes in with a "**", we split it and any text coming after the "**" is displayed on the second line with a "\r" like below
display = splits[0] + "\r" + splits[1];
Now what we need to achieve is get the splits[1] with a different formatting (style then the original one) as in the pic below. So the text comes in as Spider Man**Far from Home, we get the Far from home in a 2nd line but with different formatting as show. Whats the best way to acheive this.
Copy link to clipboard
Copied
Unfortunately, AE doesn't currently have the option to apply styles via expressions. To have two lines of text with different styles, you'll need to use two text layers. What you might be able to do though, is have an "input" text layer, then have two different text layers and use near-identical expressions to split that text as you're doing, displaying splits[0] in one layer and splits[1] in the sub layer.
Copy link to clipboard
Copied
Yes this is what i thought as a backup plan, but really wanted to get one layer working to keep the layers to a minimal and keep the project optimized. But will have to stick to this for now as AE has a limitation on expressions with style.
Copy link to clipboard
Copied
If you're talking about text you can swipe over a line if text with the type tool and make changes through the character panel for that line. Repeat.
Copy link to clipboard
Copied
Yes i know this part for manually doing it, how can i achieve the same using expressions of changing the style (font, color, size) for the same layer. I have double line (two lines), first line i need a different style, second line i need a different style but using expressions
Copy link to clipboard
Copied
While line 1 of your Text Layer is actively selected, adjust the settings in the Chracter Panel and/or Paragraph Panel. Then, select line 2 of your Text Layer and adjust the settings again.
It works just like Photoshop if you've ever adjusted Text Layers in PS.
Another approach is to apply Text Animators, using Range Selectors to adjust the characters.

