Skip to main content
Participant
October 9, 2021
Question

Can I build a reusable text animation that lets me cycle between fonts?

  • October 9, 2021
  • 5 replies
  • 1049 views

I'm creating a lyrics video for a friend and he was asking if I could make the words in the lyrics quickly change between different fonts while on the screen. 

I can obviously do this in a manual way, changing the font and the type of each layer and offsetting them, but it sounds tedious to try and do this for every single lyric in the song.

 

So I'm wondering if there is a strategy I can use to build the font cycling separate from the text and then just attach the font animation to the text layer to expedite the process? 

Here's a sample of what I'm going for: https://www.instagram.com/p/CO3FhziHWjO/?utm_medium=copy_link

This topic has been closed for replies.

5 replies

CHI-DENAuthor
Participant
October 11, 2021

I ended up just building it manually for every lyric. 

 

Built a base comp that was .5 seconds long that had 5 fonts offset by 3 frames

 

Then built a repeater comp with 10 of the base comps that lasted 5 seconds so I just had one comp for each line of text in the main composition. 

 

It was super tedious, but it seemed faster than trying to write some resuable functions that I wasn't confident I could get right. Plus this allowed me to adjust the font sizes manually to better align with each other lyric by lyric. 

 

Really appreciate everyones contributions here though. Glad / sad to know there wasn't an easy way to do it programatically before going through all of the effort manually 

Mylenium
Legend
October 10, 2021

As I wrote, it's untested code made up early in teh morning. Sure, it may need different math somewhere, but the basic principle should work.

 

Mylenium

Mylenium
Legend
October 10, 2021

If you have fixed intervals, you don't mess with conditionals, you simply divide time by the duration of the interval and associate it with an array or whatever, but depending on how many fonts there are this may not at all be more efficient than setting up individual comps and editing them together. It would look something like this:

 

mFonts=["Font a","Font b","Font c"];
mLen=mFonts.length;
mDur= 0.5;

mCur=Math.floor((time%mLen)/mDur);

mFonts[mCur]

 

The example would cycle through the three fonts on repeat based on their position in the index. just rough example code made up on the fly, needs to be refined and tested, obviously. This can then also be expanded to include random functions or additional font style code.

 

Mylenium

 

thepixelsmith
Community Expert
Community Expert
October 10, 2021

Wouldn't that give you a pause in the animation equal to  the length of the array multiplied by the duration?

thepixelsmith
Community Expert
Community Expert
October 10, 2021

Are you making  a template or just trying to save yourself some time in AE.

You can save yourself multiple layers by animating the Source Text Property of a text layer but that is still fairly manual because that property doesn't just save the font styling, it also saves the font content.

You could use the style.setFont() function to change the font family and some other properties with an expression.

 

var b = time.toFixed(1);

if(b < .5) text.sourceText.style.setFont("FuturaPT-Book");

else if(b < 1) text.sourceText.style.setFont("GurknerJump-Regular");

else if(b <= 1.5) text.sourceText.style.setFont("HelveticaNeue-CondensedBold");

else text.sourceText.style.setFont("Impact");

 

That would change the font family based on the time on the timeline.

You could then save that as a preset and reapply it to other layers.

This is the section of the help files that talk about this: https://helpx.adobe.com/after-effects/using/expressions-text-properties.html

Mylenium is right about one thing though, not all properties are accessible this way.

CHI-DENAuthor
Participant
October 10, 2021

I'm really just trying trying to save myself some time and not make it a manual process for every single word/phrase in the song selecting fonts and offsetting them.

 

That strategy is interesting, but wouldn't I still need to write the expression for each half second for the entire song?

thepixelsmith
Community Expert
Community Expert
October 10, 2021

You can save it as a preset and then apply it to text layers you want.

Mylenium
Legend
October 9, 2021

Pretty much nope. In theory you could use font style expressions, but in order for them to even work the text layer has to exist already and they still do not allow to address all font properties. That and of course you would need a million safeguards in case a font is missing or something else is botched. I would definitely not recommend going this route. As per your example it may simply be more efficient to build all the pre-comps with one clean font style and at best feed in the source text from a centralized place. Then you could do the "font change" simply by cutting the pre-comp based layers or using time-remapping on pre-comps with the cycle laid out jus tas well as you could write a script that randomly pics a comp and puts it into place. Point in case: There are ways to get some automation, but not in the way you may think and not as deep and far-reaching. AE is still limited in that department simply due to how the program works.

 

Mylenium