Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Automatically replace font on certain characters in text layer

  • Automatically replace font on certain characters in text layer

    Posted by Oscar Nyquist on August 31, 2021 at 1:36 pm

    Hello,

    I have a script for InDesign that will check a text layer for characters which are not supported by the current font (i.e. a language which uses other characters), and replace them with a different font according to a set parameter. Only affecting individual characters in that text layer.

    Now, I’m trying to create something similar in AE, but from reading older threads it seems like this is not supported by previous versions of AE. Is it possible to create something like that with the current version? To add, the content of the text layers is dynamic, so I can not use the range selector to specify the characters beforehand.

    Thanks!

    Andrei Popa replied 4 years, 12 months ago 3 Members · 4 Replies
  • 4 Replies
  • Filip Vandueren

    September 2, 2021 at 1:09 pm

    It’s possible to change the font of the entire text-layer, but not of individual characters.

    for example:

    if (value.indexOf("é")>0) {
    style.setFont("Roboto-Thin");
    } else {
    style;
    }
  • Oscar Nyquist

    September 3, 2021 at 1:09 pm

    Thanks for your reply. Ideally, I need to figure out a way to get around that limitation. I have a setup which feeds data into AE from a google sheet, and sometimes that data will mix different languages in the same sentence, like Japanese and English. The easiest solution would of course be to use a font that supports multiple languages, but I’m using a custom font which unfortunately does not have that capability.

    Do you know if there’s a way to use JS to at least detect when there are glyphs which can’t be read using the current font?

  • Filip Vandueren

    September 3, 2021 at 2:01 pm

    There should be javascript engines that can do this (I think maybe typr.js, opentype.js, or foliojs/fontkit could be used?) , but I don’t think it’s possible to embed those within an expression or extendscript.

    For something this granular, checking all glyps in a string against probably mulitple fallback fonts, I think your best bet would be to write something that can run as a pre-processing script in Google Sheets, using Google Scripts, and then create a column with the desired font for each value.

    Getting text-value + font from a .csv is perfectly do-able with expressions.

  • Andrei Popa

    September 3, 2021 at 8:46 pm

    I know this is not what you were looking for, but you can try and merge your font with fonts from the countries it is missing. There is a free family from google named Noto, where you can get any language. However, if you your texts are mixed with RTL languages(like Arabic, Hebrew) After Effects will not handle that well.

    Here is an example of how to merge two or multiple fonts: Merging two fonts – Super User

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy