Font search

What type of scripts do you need?

Moderator: byronnash

Cptzap
Posts: 5
Joined: July 15th, 2008, 5:25 am
Location: Bergen, Norway

Hi! Is it possible to make a script that can find layers that use a certain font, and/or search in text being used to find words? Like the effects search script that can find layers that uses certain effects?
In my job I have to update text in old projects that has been made by others, and it's always a time-drain to navigate through projects that sometimes look like a bombed brothel :)

- Cptzap
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

You cannot query font properties as of yet. It should be possible to find strings with indexOf() or regex(). Not sure what exactly you are looking for.

Mylenium
[Pour Mylène, ange sur terre]
strawdog
Posts: 5
Joined: November 10th, 2008, 9:35 am

I have somewhat glumly arrived at this conclusion also. I spent ages yesterday trying to find out which property I could get my script to query so that I could find out what font-family, weight and size a text layer was using without any success whatsoever.

Does anyone have any idea why this information is so hard to get or when it might likely become available? Seems at odds with how accessible everything else is.

I'm now considering either adding a custom property, or having some kind of prefix in the actual source text (the script I'm writing is for exporting animation information for our internal tech to use.)

Cheers
Simon
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

strawdog wrote:Does anyone have any idea why this information is so hard to get or when it might likely become available? Seems at odds with how accessible everything else is.
I guess you would have to spend considerable effort on it and start by separating the streams for this info in AE itself first. My knowledge is superficial at best, but handling fonts via scripts seems also complicated and limited in other Adobe apps, so it's surely a more generaic problem, probably due to the many options that need to be covered.

Mylenium
[Pour Mylène, ange sur terre]
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

After Effects CS4 added more scripting support for text properties, but I don't think the documentation is available yet. Here's an example of how you'd query and change the font and font size:

Code: Select all

{
	// select a text layer before running this script
	var activeItem = app.project.activeItem;
	var theValue = activeItem.selectedLayers[0].sourceText.value;
	
	alert("font = " + activeItem.selectedLayers[0].sourceText.value.font);
	alert("fontSize = " + activeItem.selectedLayers[0].sourceText.value.fontSize);
	
	theValue.font = "ArialMT";
	theValue.fontSize = 24;
	activeItem.selectedLayers[0].sourceText.setValue(theValue);
	
	alert("font = " + activeItem.selectedLayers[0].sourceText.value.font);
	alert("fontSize = " + activeItem.selectedLayers[0].sourceText.value.fontSize);
}
ScottHD
Posts: 11
Joined: June 14th, 2008, 9:22 pm
Location: South Carolina

I can't wait until my AE CS4 upgrade gets here so I can try that new font scripting stuff out! That would be really handy at my job.
strawdog
Posts: 5
Joined: November 10th, 2008, 9:35 am

Yes, this should be useful.
I don't suppose anyone knows if the text bounding box is available to scripts in CS4?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

There's nothing new related to that in CS4. Do you know about sourceRectAtTime() that was added in CS3? Also, maybe you've already seen that there are quite a few posts about this on here.

Paul
strawdog
Posts: 5
Joined: November 10th, 2008, 9:35 am

No I hadn't spotted that, thanks.
I guess my thread search queries weren't on the right wavelength! :)
jayse
Posts: 12
Joined: November 22nd, 2004, 5:45 pm
Location: vegas
Contact:

Lloyd gave a preview of just such a script "pt_TextEdit" at his aeny presentation a few days ago http://vimeo.com/3031889?pg=embed&sec=3031889&hd=1

only question is... Paul - WHEN??? when can we have it!? Looks excellent!

:-)
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

pt_TextEdit is undergoing a bit of a rewrite at the moment, but it should be ready within the next few weeks.

Paul
c_wall
Posts: 5
Joined: March 21st, 2009, 2:01 am

I am waiting by the phone so to speak for you to call and tell my my prince (pt_edit) is here!
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

I'm releasing betas of pt_TextEdit and pt_ExpressEdit right now. See here for details:
http://www.aenhancers.com/viewtopic.php?f=9&t=1380
http://www.aenhancers.com/viewtopic.php?f=9&t=1381
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

It took a little longer to finish than I'd anticipated but pt_TextEdit is finally released:
Watch demo and download pt_TextEdit from aescripts.com
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA
Contact:

Paul Tuersley wrote:After Effects CS4 added more scripting support for text properties, but I don't think the documentation is available yet. Here's an example of how you'd query and change the font and font size:

Code: Select all

{
	// select a text layer before running this script
	var activeItem = app.project.activeItem;
	var theValue = activeItem.selectedLayers[0].sourceText.value;
	
	alert("font = " + activeItem.selectedLayers[0].sourceText.value.font);
	alert("fontsize = " + activeItem.selectedLayers[0].sourceText.value.fontSize);
	
	theValue.font = "ArialMT";
	theValue.fontSize = 24;
	activeItem.selectedLayers[0].sourceText.setValue(theValue);
	
	alert("font = " + activeItem.selectedLayers[0].sourceText.value.font);
	alert("fontSize = " + activeItem.selectedLayers[0].sourceText.value.fontSize);
}
I'm wondering if I can use the script above that Paul wrote to manipulate multiple styles within the same text field...

For example: First name in HelveticaBld and last name in HelveticaLt on the same line. They would be in the same line so I couldn't set theValue as the selectedLayer because there would be two values for the same line... Am I making sense? :)

Would something like this work? I'm using CS5.

Code: Select all

var name = comp.layer(i).sourceText;
   
   firstNameValue.font = "Helvetica Neue LT Std";
   firstNameValue.fontstyle = "73 Bold Extended";
   firstNameValue.fontsize = 24;
   
   lastNameValue.font = "Helvetica Neue LT Std";
   lastNameValue.fontstyle = "55 Roman";
   lastNameValue.fontSize = 24;
   
   name.setValue(firstNameValue.toUpperCase() + " " + lastNameValue);
I realized that this still doesn't account for the actual text itself... firstName = shawn, lastName = baden...
Post Reply