Indesign Applescripting - problems with "Applied font"

Hey Guys,

Ok so here’s the story. I am making a script which will set up a document with elements that always have to be placed on a page. One thing I cant get is when I try to put type in a text box and make sure its the proper font it comes back with an error saying the font can not be found. I know this is not the case since I have it loaded and have used it hundreds of times. Here is the script:

tell page 1 of myDocument
set myHeaderBar to make text frame
set geometric bounds of myHeaderBar to {“.25”, “.25”, “.75”, “8.25”}
set vertical justification of text frame preferences of myHeaderBar to center align
set contents of myHeaderBar to “LENNAR®”
set fill color of myHeaderBar to “Primary - Blue”
tell paragraph 1 of myHeaderBar
set properties to {fill color:swatch “Primary - White” of myDocument}
tell paragraphs to set justification to center align
set point size to 25
set applied font to “Lennar Logo” --Font specifically designed for client.
set font style of paragraph 1 to “Expanded Heavy”
end tell

end tell

The name of this font is called “Lennar Logo” when i get info from the finder it has that as the name so I know I am referring to it correctly. The error is “Adobe InDesign CS6 got an error: The requested font family is not available.”

Any help is appricated.

Hi there,

Welcome to MacScripter!

I use the snippet of code below to check font names are correct and whether or not they differ from the Finder.

tell application "Adobe InDesign CS6"
	set usedFonts to name of fonts of active document
end tell

Give it a try to check the font name is correct. You’ll need to have the document open.

HTH

Hi Nik, thanks

where do i put this code? “set usedFonts to name of fonts of active document” I know its active because when I am in indesign it is there in the font list. I was able to make a character style but it will not apply it either…a whole new set of problems.

When I create this line of code:


set LennarStyleFont to make character style with properties {name:"lennarStyle", point size:28, applied font:"Lennar Logo", font style:"Expanded Heavy", fill color:"Primary - White", stroke color:"None"}
	

It only makes the character style AFTER i close the document…rofl…this is messed up.

THank you very much - with a little tweeking I discovered that applescript sees font names differently than normally but I did get the correct name with that code thanks!

final code:


		set myHeaderBar to make text frame
		set geometric bounds of myHeaderBar to {".25", ".25", ".75", "8.25"}
		set vertical justification of text frame preferences of myHeaderBar to center align
		set contents of myHeaderBar to "LENNAR®"
		set fill color of myHeaderBar to "Primary - Blue"
		tell paragraph 1 of myHeaderBar
			set properties to {fill color:swatch "Primary - White" of myDocument}
			tell paragraphs to set justification to center align
			set point size to 25
			set applied font to "Lennar Logo (TT)	Expanded Heavy" --apparently they put the style in the name
		end tell

Glad to hear you sorted it.

Yeah, should have said, if you run that script a list of document fonts appears in the ‘Result’ window of the Script Editor. That then allows you to check the name of the font that InDesign is using.