Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

error: applying font on paragraph style

Engaged ,
Apr 16, 2010 Apr 16, 2010

Hi All,

I am facing a problem while applying font on paragraph style. Here below is my code.

if (myDoc.paragraphStyles.appliedFont.name == "Helvetica Neue Light")

{

myDoc.paragraphStyles.appliedFont = 'Helvetica Neue LT Std';

myDoc.paragraphStyles.fontStyle = '45 Light';

}

The error is "The requested font family is not available." but fonts installed properly and working fine while i am applying manually.
If i have apply "Helvetica Neue Std 45 Light" font anywhere in my document (manual) only one time and run the script then its working fine.
Where is problem??
Any suggestion.
Thanks,
Shonky

TOPICS
Scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 16, 2010 Apr 16, 2010

The problem is, you cannot apply "'Helvetica Neue LT Std' because you don't have a style "Light" in that font; and you cannot apply the style

"45 Light" first because you don't have a "Helvetica Neue 45 Light"!

This is what they refer to as a classic "Catch-22" situation. Fortunately, there is another way: you can apply both font and style in one command:

app.activeDocument.paragraphStyles[2].appliedFont = 'Univers LT\t45 Light';

(Note the tab character inbetween font family and style.)

Quite irritat

...
Translate
Community Expert ,
Apr 16, 2010 Apr 16, 2010

The problem is, you cannot apply "'Helvetica Neue LT Std' because you don't have a style "Light" in that font; and you cannot apply the style

"45 Light" first because you don't have a "Helvetica Neue 45 Light"!

This is what they refer to as a classic "Catch-22" situation. Fortunately, there is another way: you can apply both font and style in one command:

app.activeDocument.paragraphStyles[2].appliedFont = 'Univers LT\t45 Light';

(Note the tab character inbetween font family and style.)

Quite irritating is that your way does work when applied to text, instead of a paragraph style; for a moment, you'll get a pink text in the "font" [Helvetica Neue 45 Light] and when you apply just the style, all is well again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2010 Apr 18, 2010

Thanks Jongware

Its working fine.

Can you please tell me why paragraph and character appliedFont giving different result.

var myDoc = app.activeDocument; var myparastyle = myDoc.paragraphStyles.length; for(a=1; a<myparastyle; a++) { alert (myDoc.paragraphStyles.appliedFont.name) } var mycharstyle = myDoc.characterStyles.length; for(a=1; a<mycharstyle; a++) {....appliedFont.name) }

In paragraph styles its giving font name and font style but in character styles it giving "undefined", Why?

I think result should be same in both cases but its not.

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2010 Apr 19, 2010

"Why", well, no idea really.

If you import text, Indesign is happy to add [Unknown Fonts Like This] to paragraph styles, character styles, and to plain text as well. On the other hand, you can't do this in the interface -- if you have a font "Univers LT", you cannot select "Bold" to make it [Univers LT Bold]. Then again, you can using Search and Replace: if your font is Times, you can first replace all "Bold" to "55 Bold", then replace all "Times" to "Univers LT".

It must be something inside the scripting engine. It may well be a too smart programmer, trying to "protect" you from doing this by accident ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 19, 2010 Apr 19, 2010
LATEST

Thank you very much.

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines