Highlighted

2 styles in 1 Text Layer

New Here ,
May 12, 2020

Copy link to clipboard

Copied

Hey there,

 

I have 3 Text layers. The first layer is in Semi Bold, the second is in light and the third layer should be some kind of a merge between layer 1 and layer 2 but with both styles in there.

 

At the moment I get this only with 1 style Option but  I need both in there...

 

txt1 = thisComp.layer("First Name").text.sourceText;
txt2 = thisComp.layer("Last Name").text.sourceText;
style1 = txt1.getStyleAt(0);
style2 = txt2.getStyleAt(0);

style1.setText(txt1 + " " + txt2)

 

This works in terms of Text is displayed but it only takes the style of layer 1.

 

I tryed to get both styles but the result was just [Objekt]...

 

txt1 = thisComp.layer("First Name").text.sourceText;
txt2 = thisComp.layer("Last Name").text.sourceText;
style1 = txt1.getStyleAt(0);
style2 = txt2.getStyleAt(0);

style1.setText(txt1) + " " + style2.setText(txt2)

 

On other tries I got mostely "....is not a function"

 

does someone has an idea?

I would be thankful 😉

Screen Shot 2020-05-12 at 11.57.13.png

Topics

Expressions

Views

496

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

2 styles in 1 Text Layer

New Here ,
May 12, 2020

Copy link to clipboard

Copied

Hey there,

 

I have 3 Text layers. The first layer is in Semi Bold, the second is in light and the third layer should be some kind of a merge between layer 1 and layer 2 but with both styles in there.

 

At the moment I get this only with 1 style Option but  I need both in there...

 

txt1 = thisComp.layer("First Name").text.sourceText;
txt2 = thisComp.layer("Last Name").text.sourceText;
style1 = txt1.getStyleAt(0);
style2 = txt2.getStyleAt(0);

style1.setText(txt1 + " " + txt2)

 

This works in terms of Text is displayed but it only takes the style of layer 1.

 

I tryed to get both styles but the result was just [Objekt]...

 

txt1 = thisComp.layer("First Name").text.sourceText;
txt2 = thisComp.layer("Last Name").text.sourceText;
style1 = txt1.getStyleAt(0);
style2 = txt2.getStyleAt(0);

style1.setText(txt1) + " " + style2.setText(txt2)

 

On other tries I got mostely "....is not a function"

 

does someone has an idea?

I would be thankful 😉

Screen Shot 2020-05-12 at 11.57.13.png

Topics

Expressions

Views

497

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
May 12, 2020

Copy link to clipboard

Copied

Multiple font styles in the same layer by expressions is not possible yet.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
May 12, 2020

Copy link to clipboard

Copied

Mhhh... thats bad but thanks for the answer I realy appreciate this

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
May 13, 2020

Copy link to clipboard

Copied

Ok now that I know that this is simply not Possible, I'll try it another way.

 

The goal is that I wanne have 2 Text Layers 1) First Name 2) Last Name.

I wanne to create a space between the two layers, but if I change the font in any of the layers the space needs to adjust.

an example would be: change the font from semi bold to condenced. The space between the words in semi bold is greater then it is in condenced.

 

So is there a way to create a "space" in front of the second text layer which is desplayed in the "textbox" or moves the anchor point in front of the text layer accordingly to the font?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 13, 2020

Copy link to clipboard

Copied

The sourceRectAtTime() expression method returns the height and width of any text layer. If you also consider the position of the text layer, the anchor point is set to 0, 0, and as long as the baseline shift for the layer is set to zero everything stays pretty simple. You need to also add some padding under the First Name layer. Then is just a simple matter of extracting the x position from the First name layer and adding the height plus the padding to the Y position and the height of the Last Name layer. If you always keep the scale at 100% then everything should work just fine. It's basically the same technique used to automate the size of a background shape layer. Instead of applying the expression to a shape layer you apply it to the last name layer. If you always put the Last name layer below the First Name layer and you left justify, and you don't fiddle with the anchor point or scale of the layers, this will work:

 

target = thisComp.layer(index - 1);
topLyrHeight = target.sourceRectAtTime().height;
lyrHeight = thisLayer.sourceRectAtTime().height;
pad = topLyrHeight * .6;
pos =target.position;
[pos[0], lyrHeight + pos[1] + pad]

 

replace the .6 with an Effect>Slider Control divided by 100 and save it as an animation preset and you have something you can use again and again. You can stack up as many of these layers as you want and they will all move with the top text layer.

Screenshot_2020-05-13 03.45.04_paX6uE.png

Hope that helps.

 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
May 13, 2020

Copy link to clipboard

Copied

I'm aware of sourceRectAtTimme() and thats the whole point.

I dont want to adjust the space with a slider, the goal is that it adjust itself by changing font...

and its not about stacking text layers its more about like the red marked space in this pic:

Screen Shot 2020-05-13 at 12.51.27.png

 

But thanks for answering 😉

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 13, 2020

Copy link to clipboard

Copied

That expression works just fine when you change the font of any text layer. You can switch it up and keep all the text on the same line. 

ScreenFlow.gif

This expression works if you want the text on the same line and don't want to adjust the padding:

 

target = thisComp.layer(index - 1);
topLyrWidth = target.sourceRectAtTime().width;
lyrWidth = thisLayer.sourceRectAtTime().width;
pad = topLyrWidth * .2;
pos =target.position;
[pos[0] + topLyrWidth + pad, pos[1]]

 

sameLine.gif

I put the slider in because all fonts are not created using the same formula. A 10 pt Helvetica H is not the same height or width as a 10 point Courier H - so you need an easy way to compensate for the differences in the fonts. Once the adjustment is made these expressions work with any combination of fonts and weights without manipulating anything else. 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
May 13, 2020

Copy link to clipboard

Copied

Ok I'll try it as soon as I'll get Home 😉 thanks for the help realy appreciate this!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 13, 2020

Copy link to clipboard

Copied

Try this animation preset. You can put as many layers as you line in line.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
May 13, 2020

Copy link to clipboard

Copied

So I tried it but its not realy working. Because it takes the layer width and multiplies it by 0.2. So if the Name is long like Carlos the space is extreme huge and if the Name is short like Bob the space is realy smal.

 

The space should be the same if I dont change the style but it should just change the sspace if I change the style accordingly. If it changes the space by changing the width of the Text, I will never be able to use this as an Template in PR. The easier soulution would be to use just a slider and add it to the position, so I can adjust it there...

 

But what Im lookng for is a way that works automatically when I swich a font from something like Bold zu condenced...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 13, 2020

Copy link to clipboard

Copied

If you don't want to consider the entire width change pad = topLyrWidth * .2 to pad = topLyrWidth + 10. That will give you a 10-pixel pad.  

 

The problem with using addition is that as the font size changes the padding increases. I can fix that by taking the sourseRectAtTime().height and using a percentage of that as the padding. I don't have time to work that out right now and make sure it works, but it would be a good addition to the animation preset. I will work that out later today and post a couple of presets for you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...