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: GREP
- This topic has 9 replies, 3 voices, and was last updated 5 years, 5 months ago by Michel Allio for FRIdNGE.
-
AuthorPosts
-
-
October 3, 2018 at 1:29 am #110713Alfonso IacurciParticipant
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-KfTjMdIaD5GGv6gQzdXyIVlN4I hope this makes sense.
Many thanks.
-
October 3, 2018 at 1:32 am #110715Raphael FreemanParticipant
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
-
October 3, 2018 at 4:10 am #110718Michel Allio for FRIdNGEParticipant
Hi,
Simplistically:
• Insert a Grep style:
[”‘!](?=~j\d)
char Style: “tracking +200” (sample)
• Then just play this regex:
Find: [”‘!](?=\d)
Replace by: $0~jBest,
Michel, for FRIdNGE -
October 3, 2018 at 11:27 am #110724Alfonso IacurciParticipant
@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! -
October 3, 2018 at 11:41 am #110725Raphael FreemanParticipant
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.
-
October 3, 2018 at 12:21 pm #110734Alfonso IacurciParticipant
@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. -
October 3, 2018 at 11:14 pm #110735Raphael FreemanParticipant
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.
-
October 3, 2018 at 11:39 pm #110736Alfonso IacurciParticipant
Thank you for your help Raphael.
-
October 4, 2018 at 2:44 am #110738Michel Allio for FRIdNGEParticipant
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! ;-)
-
November 13, 2018 at 10:16 am #110723Alfonso IacurciParticipant
@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.
-
-
AuthorPosts
- You must be logged in to reply to this topic.