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

GREP Styles puzzle: apply character style to the first half of every word

Community Beginner ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

I recently ran across the below text sample, apparently produced by bionic-reading.com. In this sample it's simply a matter of bolding the the first 50% (rounded up) of characters in every word, though the site gives other controls.

 

Putting aside whether this styling is actually advantageous, is there a way to implement this (bold first 50% of every word) with a GREP style? Where would you begin? 

1cw8pniva3ma1.jpg

TOPICS
Type

Views

808

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

correct answers 1 Correct answer

Guide , Mar 06, 2023 Mar 06, 2023

Capture d’écran 2023-03-06 à 22.15.53.png

 

(^/)  The Jedi

Votes

Translate

Translate
Community Expert ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

I'm not an expert in GREP - but I think you would need to search for each length separately.

 

Something like this:

 

1st step to "split" words - where "{2}" determines number of letters in each "half":

 

RobertTkaczyk_0-1678135998467.png

 

Then style upto %:

 

RobertTkaczyk_1-1678136095144.png

 

Then just remove "%" styled Bold.

 

But I'm sure someone will be able to do it in one or max two steps 😉

 

Or it could be easily scripted.

 

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
Guide ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

Capture d’écran 2023-03-06 à 22.15.53.png

 

(^/)  The Jedi

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 Beginner ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

Brute force! Sure 🙂

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
Guide ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

or (asked by op):

 

Capture d’écran 2023-03-06 à 22.23.34.png

 

(^/)

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 Beginner ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

Okay, I'll bite: what's ID-Tasker? The only hits I'm finding are your forum sig.

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 ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

😉 Tool I'm working on - you'll be able to do EVERYTHING you can do manualy in the InDesign ... so if you have 100s of INDD files that you need to Export as PDFs/JPEGs - or only some pages - or replace one image on the 5th page on the EN layer or style tables or convert some texts into Anchored TFs etc. etc - you'll be able to build Tasks from Rules - but PC only ...

 

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 ,
Mar 08, 2023 Mar 08, 2023

Copy link to clipboard

Copied

You can do it e.g. with the script below, for all stories in the active document. The script gives the character style 'bold', so you have to define it beforehand.

 

var doc = app.activeDocument;
for (var s = 0; s < doc.stories.length; s++){
	for (var w = 0; w < doc.stories[s].words.length; w++){
		for (var c = 0; c < Math.ceil(doc.stories[s].words[w].length/2); c++){
			doc.stories[s].words[w].characters[c].appliedCharacterStyle = 'bold';
			}
		}
	}

 

Alternatively, for selected text frames, not including overflow text:

var selTextFrames = app.selection;
for (var t = 0; t < selTextFrames.length; t++){
	for (var w = selTextFrames[t].words.length-1; w >=0 ; w--){
		if (selTextFrames[t].words[w].isValid){
			for (var c = 0; c < Math.ceil(selTextFrames[t].words[w].length/2); c++){
				selTextFrames[t].words[w].characters[c].appliedCharacterStyle = 'bold';
				}
			}
		}
	}

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 ,
Mar 08, 2023 Mar 08, 2023

Copy link to clipboard

Copied

Nice. 

 

But instead of inside for() to apply CharStyle - you can get the number of chars - from .ceil() - and use itemByRange - I'm not JS guy and replying from my phone so... 

 

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
Guide ,
Mar 19, 2023 Mar 19, 2023

Copy link to clipboard

Copied

LATEST

The "word" javascript syntax remains to me [personal] truly bad!

 

Capture d’écran 2023-03-19 à 13.42.49.png

 

(^/)

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