Page 1 of 2

Font search

Posted: September 11th, 2008, 10:27 pm
by Cptzap
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

Re: Font search

Posted: September 19th, 2008, 9:45 am
by Mylenium
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

Re: Font search

Posted: November 10th, 2008, 10:55 am
by strawdog
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

Re: Font search

Posted: November 10th, 2008, 12:24 pm
by Mylenium
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

Re: Font search

Posted: November 11th, 2008, 3:05 am
by Paul Tuersley
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);
}

Re: Font search

Posted: November 14th, 2008, 10:01 am
by ScottHD
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.

Re: Font search

Posted: November 20th, 2008, 9:49 am
by strawdog
Yes, this should be useful.
I don't suppose anyone knows if the text bounding box is available to scripts in CS4?

Re: Font search

Posted: November 20th, 2008, 1:04 pm
by Paul Tuersley
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

Re: Font search

Posted: November 20th, 2008, 2:39 pm
by strawdog
No I hadn't spotted that, thanks.
I guess my thread search queries weren't on the right wavelength! :)

Re: Font search

Posted: February 21st, 2009, 10:01 am
by jayse
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!

:-)

Re: Font search

Posted: February 23rd, 2009, 1:01 pm
by Paul Tuersley
pt_TextEdit is undergoing a bit of a rewrite at the moment, but it should be ready within the next few weeks.

Paul

Re: Font search

Posted: April 30th, 2009, 6:54 pm
by c_wall
I am waiting by the phone so to speak for you to call and tell my my prince (pt_edit) is here!

Re: Font search

Posted: May 7th, 2009, 3:50 am
by Paul Tuersley
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

Re: Font search

Posted: February 2nd, 2010, 3:32 pm
by Paul Tuersley
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

Re: Font search

Posted: October 13th, 2010, 9:57 am
by sbaden
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...