Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Count the number of glyphs in a text layer

  • Count the number of glyphs in a text layer

  • Andrei Popa

    May 27, 2021 at 10:33 am

    Hi guys. I really hope someone can shed some light on this problem.

    I am working with some RTL texts and I want to highlight words based on their position. I can count from end to start in order to reverse the animator but the thing is that JavaScript and after effects animator count the characters in a different way. So JavaScript .indexof() function does not count the characters in the same way that the animator range does.

    Ex: if I use “لى” as text source, animator says it is 1 character while text.sourceText.length says it is 2. If I have one of two of this in my string, the whole thing works badly. Is there any way to either make the animator count this as 2 or make JS see it as one?

    As a side information, I noticed that animator does the same thing for “fi” or other ligature in the fonts that have them. If your font has the “fi” ligature, AE counts it as one char.

  • Filip Vandueren

    May 28, 2021 at 11:20 am

    There is no way for javascript to know. Javascript deals in strings, and lets the renderer decide how to display that (Ligatures or not, for example), So I think it’s the same as in the Browser: you can’t know.

    I don’t know if it totally breaks legibility but is disabling ligatures an option ?

  • Andrei Popa

    May 31, 2021 at 11:37 am

    Thanks for the answer Filip.

    Disabling ligatures does not work for Arabic text. I think the only solution is to check the font and get all the “required” ligatures in an array and then subtract the number of occurrences of any of those ligature from the main text.

  • Filip Vandueren

    May 31, 2021 at 12:41 pm

    I thought something similar, but where can you find the list of characters that will form a ligature for a given font?

  • Andrei Popa

    June 10, 2021 at 8:17 pm

    I cant remember exactly the name, but I found a forum post which gave some indications towards a light, free software that shows fonts “architecture”. All the glyphs, ligatures and such. I wish I didn’t close that tab 😀

Viewing 1 - 5 of 5 posts

Log in to reply.

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