If you want to cycle through different fonts for your onscreen text in After Effects, this expression will make it easy for you. First, you’ll need to make an array with all the possible fonts you want.
You’ll need to have the proper font name listed. An easy way to that is to go to the Expression Language menu (triangle button), go to Text and then select Font. This allows you to scroll through different fonts and font weights. When you select one, it will import the proper font name.
With your array complete, you can type the following to select a value (font) from the array. Remember, the first item listed in an array is “0” and the second item is “1” … and so on.
You’ll want to replace the number in brackets with variable for a slider control. This will help you quickly keyframe your fonts. Add a slider control to your layer. Then, create a variable, type Math.round so you can deal with whole number values that the array needs, and pickwhip to your slider control effect.
v = Math.round(effect(“Slider Control”)(“Slider”));
Now, you can replace the 0 in brackets with this variable (“v” in this instance), so the array chooses the value designated by the slider control value.
The final expression is as follows:
Please watch this short tutorial video to see it in action.