Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How do you adjust the styles of a text layer on a per character basis?

  • How do you adjust the styles of a text layer on a per character basis?

    Posted by Eric Wescott on August 25, 2014 at 5:41 pm

    I’m using a script to import a subtitles from an SRT file so I can bake subtitles into my video. The script works by reading the subtitle file and creating markers on a text layer at the proper timecode containing the actual text for the subtitle. Then there is an expression on the “Source Text” property actually display the imported subtitle based on the nearest marker.

    n = 0; t = 0;
    mySubtitle=""

    if (marker.numKeys > 0) {
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time) n--;
    }

    if (n > 0)
    mySubtitle=marker.key(n).comment;

    mySubtitle;

    However, it seems to lack the ability to properly process <b></b> and <i></i> tags in my subtitle file. I’d like to add that functionality but I’m not sure how to modify these properties on a per character basis.

    I understand how to write the code to parse the mySubtitle string to strip out the tags and store the start/end locations of the characters to modify their style but I can’t figure out how to actually make a section of text bold or italics accordingly.

    is there some sort of
    mySubtitle[start,end].font.style.bold=true
    or
    mySubtitle[start,end].font.style.italics=true
    functionality? I assume it’s possible to adjust font styles on a per character basis because I can manually do it by making selections and adjusting settings in the character window but I can’t find how to do it in the AE CS6 Scripting Guide.

    Dan Ebberts
    replied 11 years, 8 months ago
    2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    August 25, 2014 at 6:06 pm

    Unfortunately that functionality isn’t available. Once a script or expression touches the source text, all the characters get the same formatting as the first character.

    Dan

  • Eric Wescott

    August 25, 2014 at 6:36 pm

    How can you do it manually then? Is it just something you can’t do via scripting because of some limitation?

  • Dan Ebberts

    August 25, 2014 at 6:58 pm

    >Is it just something you can’t do via scripting because of some limitation?

    Correct.

    Dan

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