Copy link to clipboard
Copied
Hello all,
I am trying to create a script for textframe which i can used everytime, because most of content is similar for every document.
i tried this one
var myDocument = app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["12p", "35p", "10p", "10p"];
myTextFrame.contents = "Ā®/ā¢ Ā©2020. All rights reserved.";
myTextFrame.parentStory.appliedFont = "Helvetica NeueLT Std 55 Roman"//Change with the name of the font you want
but error occured that font family is not available , actually its available in system.
please help me to sort out this issue
Copy link to clipboard
Copied
Hi,
Try with only the font family name.
myTextFrame.parentStory.appliedFont = "Helvetica NeueLT Std"
Worked here with Arial.
If you need to specify the font style, you can write
myTextFrame.parentStory.fontStyle = "55 Roman"
or
myTextFrame.parentStory.paragraphs [i].fontStyle = "55 Roman"
Copy link to clipboard
Copied
yes i tried with Helvetica LT Std and was working but not for Helvetica Neue LT Std
Copy link to clipboard
Copied
The createMissingFontObject method should work:
var myDocument = app.documents.add();
//parameters fontFamily, fontStyleName, postscriptName
var myMF = myDocument.createMissingFontObject ("Helvetica NeueLT Std 55 Roman", "Roman", "Helvetica NeueLT Std 55-Roman")
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["12p", "35p", "10p", "10p"];
myTextFrame.contents = "Ā®/ā¢ Ā©2020. All rights reserved.";
myTextFrame.parentStory.appliedFont = myMF
Copy link to clipboard
Copied
Nice function. Where did you unearth that from?
Here works the following code.
var myMF = myDocument.createMissingFontObject ("Helvetica Neue LT Std", "55 Roman", "Helvetica Neue LT Std 55-Roman")
Copy link to clipboard
Copied
It is a document method in the API:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html#d1e49241__d1e52945
Copy link to clipboard
Copied
Hi bgfrhlp,
believe it or not, document method createMissingFontObject() is in InDesign CC 2015 version 11 or above.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thanks for the link! I've been reading an old object model reference, I believe. š
Copy link to clipboard
Copied
Hi patilg5,
then troubleshoot it the following way:
Set some text with the desired font.
Select some text with the desired font.
Run the following code:
var textFrame = app.documents[0].pages[0].textFrames.add();
textFrame.properties =
{
geometricBounds : ["12p", "35p", "10p", "10p"] ,
contents : "Ā®/ā¢ Ā©2020. All rights reserved."
};
textFrame.parentStory.texts[0].appliedFont =
app.selection[0].appliedFont ;
If that is working as expected find the appropriate string for the applied font's name:
var textFrame = app.documents[0].pages[0].textFrames.add();
textFrame.properties =
{
geometricBounds : ["12p", "35p", "10p", "10p"] ,
contents : app.selection[0].appliedFont.name
};
textFrame.parentStory.texts[0].appliedFont =
app.selection[0].appliedFont ;
I would guess there is somewhere a tab in the name where you currently think there is a blank.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Yes, the font name requires a tab. In AppleScript we define it as:
set fontStr to familyName & " " & fontSttyle //tab is between quotes
if status of font fontSttr = installed then ... //to check if the font is installed
Copy link to clipboard
Copied
The JS createMissingFontObject works whether or not the font is installed. Its fontFamily parameter doesnāt include a tabāits just the name with no style. Style is the 2nd parameter.
I donāt think the equivalent is available in the AS dictionary.