Adding space between punctuation and superscript with GREP

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Adding space between punctuation and superscript with GREP

Tagged: 

Viewing 9 reply threads
  • Author
    Posts
    • #110713
      Alfonso Iacurci
      Participant

      Hi!

      I’ve been searching to no avail, and I wonder if you can help…

      I’m looking for a GREP to apply spacing between punctuation and a superscript. The font I’m using has issues where a ” or ‘ or ! is very close to a superscript number that comes after it. So:

      “1
      Where the 1 is superscript is very tight. The superscripts have a character style applied.

      I want it to be more like:
      ” 1
      I’ve managed to achieve this by applying tracking to the ” with a character style.

      My problem is that I’m doing this by find and change, and I have over a 1000 superscripts. Each find seems to take an age.

      My hope is that there is a GREP to apply a style to the punctuation and leave the superscript with its own style.
      https://drive.google.com/open?id=15uK9xu-KfTjMdIaD5GGv6gQzdXyIVlN4

      I hope this makes sense.

      Many thanks.

    • #110715
      Raphael Freeman
      Participant

      I would solve the problem (and in fact use this method in every book I typeset), but using kerning.

      Peter Kahrel has a kerning script: https://www.kahrel.plus.com/indesign/kern.html

      I also talk about this on a video that I did on the subject: https://www.youtube.com/watch?v=P4YPcTK91xw

    • #110718

      Hi,

      Simplistically:

      • Insert a Grep style:

      [”‘!](?=~j\d)

      char Style: “tracking +200” (sample)

      • Then just play this regex:

      Find: [”‘!](?=\d)
      Replace by: $0~j

      Best,
      Michel, for FRIdNGE

    • #110724
      Alfonso Iacurci
      Participant

      @Raphael
      Thank you, this really helped! I managed to get Peter’s script to work. However, there is the small issue with the superscript set in a sans serif, and body copy in a serif, two different typefaces. I wonder if there’s a way for a generic kerning data file to exist to catch all typefaces for this purpose?

      @FridNGE
      Thank you, it worked a treat. However, I should have probably mentioned I pull in live text from Google Doc using Emsoftware DocsFlow, which in my workflow forbids me editing the text in InDesign. This GREP unfortunately inserts a character space between the ” and superscript. Raphael’s kerning advice is more of a solution, although, still not quite there… yet!

    • #110725
      Raphael Freeman
      Participant

      Yes, unfortunately Peter Kahrel’s script doesn’t work with different fonts. I may have a different solution for you with another script. I will try and remember to check that for you.

    • #110734
      Alfonso Iacurci
      Participant

      @Raphael
      Thank you! I have however used a cheat. By changing my superscript style to the same font used in the body. I ran the script, which obviously worked, and then changed the super style font back to the sans. Thank you so much for your help.

    • #110735
      Raphael Freeman
      Participant

      so I checked my older kerning script which is no where near as efficient as Peter’s and unfortunately that won’t solve your problem so your “cheat” was the best solution.

    • #110736
      Alfonso Iacurci
      Participant

      Thank you for your help Raphael.

    • #110738

      As Jacquouille la Fripoulle [“Okay! ……”] in the movie “The Visitors” or Gaston Lagaffe [“M’enfin! …”] in the comic strip of the same name, I thought Raphael would launch his famous call: ” Akiwa! … “, but not this time! ;-)

      Simplistic view:

      Adjust the kerning value between ” or ‘ or ! and a number when the font used is Arial and the number is superscript!

      // by FRIdNGE [October 2018]

      //————————————————–
      var myFindWhat = “[”‘!]\\d”,
      myAppliedFont = “Arial”,
      myKerning = 500,
      myCharPosition = Position.SUPERSCRIPT;
      //————————————————–

      app.findGrepPreferences = null;
      app.findGrepPreferences.findWhat = myFindWhat;
      app.findGrepPreferences.appliedFont = myAppliedFont;
      myFound = app.activeDocument.findGrep();
      var F = myFound.length, f,
      myCounter = 0;
      for ( f = 0; f < F ; f++ ) {
      if ( myFound[f].insertionPoints[1].kerningValue != myKerning && myFound[f].characters[1].position == myCharPosition ) {
      myFound[f].insertionPoints[1].kerningValue = myKerning;
      myCounter++
      }
      }
      app.findGrepPreferences = null;

      alert(“Done! … [” + myCounter + “]\rby FRIdNGE, october 2018”)

      Have a good day! ;-)

    • #110723
      Alfonso Iacurci
      Participant

      @Raphael Thank you for your reply. I got to 14.35 in the video, but it seemed to jump. I’m assuming this is where you introduce us to Peter’s script?! I’m still trying to get my head round Peter’s instructions running the script, but your video was very useful along side it. Do let me know if there’s an uncut version…. and thank you, there is definitely a fix to my problem here.

      @FRidNGE Thank you. I managed to get your idea working. However, it looks like it adds a character into the text. I’m more interested in adding kerning. I use Emsoftware Docsflow, with editors contributing and editing to the text in Google Docs. I’m forbidden to edit the text in anyway in InDesign as it causes conflicts. Still, thank you for your time.

Viewing 9 reply threads
  • You must be logged in to reply to this topic.
>