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

Problem with loading font in Javascript command: appliedFont

New Here ,
Jan 27, 2010 Jan 27, 2010

Copy link to clipboard

Copied

hi, i have write a javascript to run in indesign cs4. I have loaded 3 font family: Trajan, Helvetica and New Caledonia

As i am step thru' the code to load the font, i encounter strange problem:

---------------------------------------------------------------------------

    var sty = doc.paragraphStyles.add({name:styName});

    sty.appliedFont = "Trajan";  // -- always ok. It has a "Regular" style. I can use any other font as long as has "Regular" style

// however the immediate code will fail as it complains "The requested font family is not available" .

// It will only work if in Indesign, i select the font type to "New Caledonia" before the step thru the code

    sty.appliedFont = "New Caledonia";

// The code will again fail  as it complains "The requested font family is not available" UNLESS i select the Font in Indesign as  "Helvetica" too

// Very very strange...

    sty.appliedFont = "Helvetica";

------------------------------------------------------------------------------

However, if i use the 3 fonts family that has a "Regular" style , the 3 line of code will be ok...

Both the Helvetica and New Caledonia DOES NOT have "Regular" style..

HELP

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

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
New Here ,
Jan 27, 2010 Jan 27, 2010

Copy link to clipboard

Copied

I am using Window version of Indesign CS4...


Votes

Translate

Translate

Report

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
New Here ,
Jan 27, 2010 Jan 27, 2010

Copy link to clipboard

Copied

LATEST

hi Uwe, i think i didnt write clear enuff...

i have installed Trajan, Helvetica and New Caledonia into my PC.

When i launch CS4 , i can see that Trajan has Regular style but not the other 2 ( which i dont know why. I can see it in WinWord)

i step thru my script using ExtendScript ToolKit using the below script snippet to test the 3 font.

---------------------------------------------------------------------------

    var sty = doc.paragraphStyles.add({name:styName});

    sty.appliedFont = "Trajan";

    sty.appliedFont = "New Caledonia";

    sty.appliedFont = "Helvetica";

------------------------------------------------------------------------------

When i step to "Trajan" line, it's ok. But the next step will fail, which i dont understand. I have New Caledonia font.

But it complaint "The requested font family is not available"..

Now, before i  step thru the script again, i purposely go to ID CS4 to set the font menu to "New Caledonia" ( at the top left hand corner )

Now when i step thru, the "Trajan and "NEw Caledonia" line is ok, BUT the script will fail at the next "Helvetica" line...

Strange enuff...i am lost...

However, if i change to following script, it will step thru successfully...All the below 3 fonts has "Regular" style

    sty.appliedFont = "Trajan";

    sty.appliedFont = "Times New Roman";

    sty.appliedFont = "Arial";

Any advise?? =(

Message was edited by: fuzzyericlim

Votes

Translate

Translate

Report

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 ,
Jan 27, 2010 Jan 27, 2010

Copy link to clipboard

Copied

Hi, fuzzyericlim!
Use "fontStyle" for your font weight to define the style as well.

Example:
sty.appliedFont = "Univers";
sty.fontStyle="55 Roman";

Uwe

Votes

Translate

Translate

Report

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