Skip to main content
13H
Inspiring
June 24, 2016
Answered

How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.

  • June 24, 2016
  • 2 replies
  • 1518 views

Is there a way I can create a new paragraph style using a font that is not loaded?

  myParagraphStyle.appliedFont = "Shift";

  myParagraphStyle.fontStyle = "Book";

  // error: The requested font family is not available.

Note: I don't want to load the font with the script! Indesign should show a nice pinky colour on the text with this style applied to it.

This topic has been closed for replies.
Correct answer Laubender

CoverBuilder wrote:

… The only way I can think of doing this is making an IDML snippet . . .

What is your exact version of InDesign?
On what OS?

Working with an IDMS file could maybe help, but is less elegant perhaps.

Changing the contents of an IDMS file could be a convoluted process as well:

1. Duplicate the paragraph style you want to add a new, not installed font with a new name.

2. Add a text frame using the duplicated paragraph style.

3. Export a snippet of the text frame.

4. Open the snippet as text file with "e" for edit.

6. Read out its contents.

Replace the name of the font family and the name of the font style with by using a regular expression or by assigning the text to an XML object and using an XML method to change the values.

However, this could be impossible, if the paragraph style is e.g. based on the "[Basic Paragraph Style]" and the used font is the same as in the one that it is based on. Then the properties for the font are missing in the IDMS.

Write the new contents to the file.

7. Remove the temp text frame. Remove the duplicated paragraph style.

8. Place the edited snippet.

( 7-8: When placing a snippet the incoming formatting of a style will only rule, if the style is not there. )

9. Remove the paragraph style you want to change and exchange it with the new paragraph style that was imported through the snippet.

Not tested.

Regards,

Uwe

2 replies

ava74628296
Inspiring
June 24, 2016

You can not do script if there is no in application. First looking for how do it with not script

13H
13HAuthor
Inspiring
June 27, 2016

Yes, unfortunately it seems we have to load the font at least once at some point.

A couple of things we could do, is load the paragraph style from a previously created document, shared style in Adobe Cloud or Library. None of these are elegant.

LaubenderCommunity ExpertCorrect answer
Community Expert
June 27, 2016

CoverBuilder wrote:

… The only way I can think of doing this is making an IDML snippet . . .

What is your exact version of InDesign?
On what OS?

Working with an IDMS file could maybe help, but is less elegant perhaps.

Changing the contents of an IDMS file could be a convoluted process as well:

1. Duplicate the paragraph style you want to add a new, not installed font with a new name.

2. Add a text frame using the duplicated paragraph style.

3. Export a snippet of the text frame.

4. Open the snippet as text file with "e" for edit.

6. Read out its contents.

Replace the name of the font family and the name of the font style with by using a regular expression or by assigning the text to an XML object and using an XML method to change the values.

However, this could be impossible, if the paragraph style is e.g. based on the "[Basic Paragraph Style]" and the used font is the same as in the one that it is based on. Then the properties for the font are missing in the IDMS.

Write the new contents to the file.

7. Remove the temp text frame. Remove the duplicated paragraph style.

8. Place the edited snippet.

( 7-8: When placing a snippet the incoming formatting of a style will only rule, if the style is not there. )

9. Remove the paragraph style you want to change and exchange it with the new paragraph style that was imported through the snippet.

Not tested.

Regards,

Uwe

tpk1982
Legend
June 24, 2016

yes we can, maybe the below code is useful to start

var usedFonts = app.activeDocument.fonts;

  for (var i=0; i<usedFonts.length; i++) {

  if(usedFonts.status != FontStatus.INSTALLED){

13H
13HAuthor
Inspiring
June 24, 2016

How is it useful? I already know the font is not installed But I can't seem to set the font name as a paragraph style without activation the font. The only way I can think of doing this is making an IDML snippet . . .

tpk1982
Legend
June 24, 2016

You can get the missing fonts name....

var missingFonts = new Array()

var usedFonts = app.activeDocument.fonts; 

  for (var i=0; i<usedFonts.length; i++) { 

  if(usedFonts.status != FontStatus.INSTALLED){ 

        missingFonts.push("   "+usedFonts.name+"\n")

  alert(missingFonts);

  } 

  }