Copy link to clipboard
Copied
Preface - I don't know how to code or script at all, but I understand what it can do to an extent.
I'm looking for a JavaScript or Extendscript (or expression?) for converting text which includes the text formatting code <i> </i> around it actually into italics on After Effects text layers.
I have a script that imports SRT files and converts them into text layers but these text layers have the html code <i> around certain words which were originally italicised in another application. I need these words inside this code to be become italicised and the html code gone basically.
I hope this makes sense as I've never wrote a code in my life but I know how to run a script in After Effects so hoping someone can work their magic for me!
Copy link to clipboard
Copied
With expressions you can set the "Faux Italics" property of a text, but as far as I know, you can do that only for the entire text and not for individual words:
https://helpx.adobe.com/after-effects/using/expressions-text-properties.html
With scripts it is also not possible to set the style of individual words of a text. Hence, if you don't want to do it manually, the only solution will probably be to split the text into multiple layers, which is pretty complex.
Copy link to clipboard
Copied
Thank you for your reply!
The SRT importer which I use splits the SRT file 'captions' into separate text layers so that it's not one text layer.
Do you mean that the italicised text would need to be split into it's own layer entirely without any other unformatted words in that layer for a script to potentially work at coverting the italic tags?
With me not knowing anything about scripting, I was wondering would there be a sort of
Fetch all words inside "<i>" and "</i>" on all text layers
Set Faux Italics property of text
Delete <i> </i> tag
This is the sort of idea I had in my head but maybe it's not possible.
The reason I would like this is that I have many long SRT files which have <i> incorporated into them upon import and I have to manually change the formatting on them all and it would save me a lot of time everyday and prevent me missing any of them. Wishful thinking perhaps!
Copy link to clipboard
Copied
I created a script that imports SRT subtitles and also supports <i>, <b> style tags.
https://aescripts.com/pt_importsubtitles/
As Mathias said, AE doesn't have scripting support for setting multiple styles on a single text layer, so I had to jump through a lot of hoops to get it working. Not something I'd suggest tackling yourself if you're a newcomer to scripting.