7 Replies Latest reply on Jun 27, 2016 5:06 AM by CoverBuilder

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

    CoverBuilder Level 1

      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.

        • 1. Re: How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.
          tpk1982 Level 4

          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[i].status != FontStatus.INSTALLED){

          • 2. Re: How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.
            CoverBuilder Level 1

            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 . . .

            • 3. Re: How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.
              tpk1982 Level 4

              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[i].status != FontStatus.INSTALLED){ 

                      missingFonts.push("   "+usedFonts[i].name+"\n")

                alert(missingFonts);

                } 

                }

              • 4. Re: How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.
                ava74628296 Level 1

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

                1 person found this helpful
                • 5. Re: How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.
                  CoverBuilder Level 1

                  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.

                  • 6. Re: How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.
                    Laubender Adobe Community Professional & MVP

                    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

                    • 7. Re: How to specify appliedFont and fontStyle to a paragraph style without the font being loaded.
                      CoverBuilder Level 1

                      Thanks for your reply! I use ID CC2015 on MacOs.

                       

                      It would be nice if we could set it from a string! But then again, there could be a font with the same name that is not the same font? I have multiple (different) copies/cuts of Helvetica Regular for example.

                       

                      Just had a look what else IDML saves about the font as it seems pretty clever in recognizing that this Helvetica Regular is not that Helvetica Regular.

                       

                      Fonts.XML:

                      <FontFamily Self="dif5" Name="Special Elite">
                          <Font Self="dif5FontnSpecial Elite Regular" FontFamily="Special Elite" Name="Special Elite Regular" PostScriptName="SpecialElite-Regular" Status="Installed" FontStyleName="Regular" FontType="TrueType" WritingScript="0" FullName="Special Elite" FullNameNative="Special Elite" FontStyleNameNative="Regular" PlatformName="$ID/" Version="Version 1.000" TypekitID="$ID/" />
                      </FontFamily>
                      

                       

                      Styles.XML

                      <ParagraphStyle Self="ParagraphStyle/TEST" Name="TEST" Imported="false" NextStyle="ParagraphStyle/TEST" SplitDocument="false" EmitCss="true" StyleUniqueId="0663090e-607d-4118-8d5b-a1ebd6d321b0" EmptyNestedStyles="true" EmptyLineStyles="true" EmptyGrepStyles="true" KeyboardShortcut="0 0">
                        <Properties>
                          <BasedOn type="string">$ID/[No paragraph style]</BasedOn>
                          <PreviewColor type="enumeration">Nothing</PreviewColor>
                          <AppliedFont type="string">Special Elite</AppliedFont>
                        </Properties>
                      </ParagraphStyle>
                      

                       

                      Not sure what the StyleniqueID is for? Interestingly after doing some tests, you can change the name of the font in the font tags or style outline but ID auto-correct itself. To my surprise . . . InDesign is not crashing!