3 Replies Latest reply on Sep 16, 2016 2:00 AM by Loic.Aigon

    Scripting ♀ 9mm ♂ 7mm with character styles

    robertwhyte Level 1

      I am writing a field guide where each photo has a caption in Myriad Pro part of which is ♀ 9mm ♂ 7mm (the actual measurements in mm vary). Because the font doesn't seem to support the ♀  ♂ characters I have a character style +Arial + Bold

       

      This works fine. The bold is not necessary, it just makes the style easier to see if applied to a stray text instead of those male and female symbols.

       

      I use "type it for me" to enter ♀ 9mm ♂ 7mm with a shortcut. ♀ 9mm ♂ 7mm

       

      Is there a scripting (or other) way to to this so it can be done in one go and tied to a short cut?

       

      It would seem to be something like:

       

      type ♀

      select ♀

      apply character style "MFsymbols"

      type space

      select space

      apply character style "None"

      type 9mm space

      type ♂

      select ♂

      apply character style "MFsymbols"

      type space

      select space

      apply character style "None"

      type 7mm space

       

      Thanks

        • 1. Re: Scripting ♀ 9mm ♂ 7mm with character styles
          Stefan Rakete Level 2

          Here is a start with a script

           

          // place your cursor in a textFrame and have Arial as font

          // The Glyph ID you can find in the Glyph palette

          // Select an Insertion Point

           

          var CHARACTER_FEMALE = "\u2640";

          var CHARACTER_MALE = "\u2642";

           

          var curSelection = app.selection[0];

           

          if (curSelection.constructor.name == "InsertionPoint") {

             

              curSelection.contents =  CHARACTER_FEMALE;  

              //curSelection.contents =  CHARACTER_MALE;  

           

          }

           

          Thanks Stefan

          • 2. Re: Scripting ♀ 9mm ♂ 7mm with character styles
            Obi-wan Kenobi Adobe Community Professional

            Hi,

             

            If I understand well what you mean, apply a Keyboard shortcut to this script and try:

             

            CS = app.activeDocument.selection[0].insertionPoints[0].appliedCharacterStyle;  
            app.activeDocument.selection[0].insertionPoints[-1].appliedCharacterStyle = "MFsymbols";  
            app.activeDocument.selection[0].insertionPoints[-1].contents = "\u2640";  
            app.activeDocument.selection[0].insertionPoints[0].appliedCharacterStyle = CS; 
            app.activeDocument.selection[0].insertionPoints[-1].contents = " 9mm ";
            app.activeDocument.selection[0].insertionPoints[-1].appliedCharacterStyle = "MFsymbols";  
            app.activeDocument.selection[0].insertionPoints[-1].contents = "\u2642";  
            app.activeDocument.selection[0].insertionPoints[0].appliedCharacterStyle = CS; 
            app.activeDocument.selection[0].insertionPoints[-1].contents = " 7mm ";
            

             

            [not tested]

             

            (^/)

            1 person found this helpful
            • 3. Re: Scripting ♀ 9mm ♂ 7mm with character styles
              Loic.Aigon Adobe Community Professional
              Because the font doesn't seem to support the ♀  ♂ characters

              Have you considered creating a font of yours with InDyFont ? You could pick the default font you want like Myriad and redefine shape for the \u2640 et \u2642 characters so they match the pictos of Male & Female.

               

              No scripting here but something you could easily reuse somewhere else.

              Indiscripts :: IndyFont | Build OpenType Fonts from within InDesign!

               

              FWIW

              Loic

              1 person found this helpful