• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
7

Find/replace font size with decimal value

Contributor ,
Oct 18, 2023 Oct 18, 2023

Copy link to clipboard

Copied

Hi all,

I have to replace all 15,7 points texts to 15 points. Find/Change dialog does let me enter a decimal value, but somehow I could not get it to find a decimal value. I also tried the script below, but no luck šŸ˜ž

var doc = app.activeDocument;

app.findGrepPreferences=app.changeGrepPreferences=null;
app.findGrepPreferences.pointSize = "15,7pt";
app.changeGrepPreferences.pointSize = "15pt"
doc.changeGrep();

Does anyone know a workaround?

Thanks,
Rogerio

TOPICS
How to , Scripting

Views

499

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 ,
Oct 18, 2023 Oct 18, 2023

Copy link to clipboard

Copied

Have you tried searching for the number, rather than the string? 

app.findGrepPreferences.pointSize = 15.7;

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
Contributor ,
Oct 19, 2023 Oct 19, 2023

Copy link to clipboard

Copied

Hey @m1b, I gave it a try, but no luck. It seems that Find/Change doesn't work with decimal values.

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 ,
Oct 19, 2023 Oct 19, 2023

Copy link to clipboard

Copied

It should be posibble, i tested it in the latest version of indesign. 

 

Make sure you have nothing in the "Search for (zoeken naar)" and "change to (wijzigen in)" fields,
otherwise is searches for that input in the styles you entered. 


Tip for next time, work with paragraph styles, then you only had to change that paragraph style.

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
Contributor ,
Oct 19, 2023 Oct 19, 2023

Copy link to clipboard

Copied

Hi @Tammoh , thanks for getting back to me šŸ™‚

I can enter the decimal value on Find Format, but when I click on "Find Next" it doesn't find anything. Weird, right?

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 ,
Oct 19, 2023 Oct 19, 2023

Copy link to clipboard

Copied

The only truly consistent way to accomplish this may be to apply styles to the entire document. Ad-hoc style search and replace is always limited by one factor or another.


ā”‹ā”Š InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ā”Š (Amazon) ā”Šā”‹

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
People's Champ ,
Oct 19, 2023 Oct 19, 2023

Copy link to clipboard

Copied

It's perhaps not so strange.

If somebody applied a value of, say, "3mm" to some text, InDesign will convert that to a pt value, and will display 8.504.

However, searching for font with the size 8.504 won't work, because really, the text size is 8.50393700787402.

But even searching for 8.50393700787402 won't work!

The only thing that seems to work is to type 3mm in the Find What point size field. This is immediately be turned into 8.504, but it will actually find the relevant text.

So.... perhaps your best bet is to try and figure out what the original unit was, and type the find-what size in those original units?

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 ,
Oct 19, 2023 Oct 19, 2023

Copy link to clipboard

Copied

@Tį“€W has perfectly pinpointed the issue.

 

My contribution is the following script, that takes the guesswork out by requiring the userā€”Hi @Rogerio5C09!ā€”to select a bit of text first. That way we can just pass the actual pointSize to the findGrep.

- Mark

 

/**
 * Set PointSize With ChangeGrep.js
 * Will find any text in the document with
 * pointSize matching the selected text's
 * pointSize and set it to a chosen value.
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/is-there-a-way-to-remove-all-the-unused-data-placeholders/m-p/14172138
 */
function main() {

    var doc = app.activeDocument;

    setPointSize(doc, doc.selection[0], undefined);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Set Point Size');


/**
 * Sets the pointSize of any text found in `target` object
 * that matches pointSize of `sourceText`.
 * Used in case where it is difficult to manually target
 * a particular pointSize due to obscured unit conversion.
 * @author m1b
 * @date 2023-10-20
 * @param {Application|Document|Story|Text} target - the changeGrep target object.
 * @param {Text} sourceText - the text with pointSize to find.
 * @param {String|Number} [newPointSize] - the pointSize to set (default: ask user).
 */
function setPointSize(target, sourceText, newPointSize) {

    if (
        target == undefined
        || target.changeGrep == undefined
    )
        throw Error('setPointSize: bad `target` parameter.');

    if (
        sourceText == undefined
        || !sourceText.hasOwnProperty('pointSize')
    )
        throw Error('setPointSize: bad `sourceText` parameter.');

    newPointSize = newPointSize
        || prompt('Change to pointSize', sourceText.pointSize);

    if (newPointSize == undefined)
        return;

    app.findGrepPreferences = NothingEnum.NOTHING;
    app.changeGrepPreferences = NothingEnum.NOTHING;

    // get the point size from the selected text
    app.findGrepPreferences.pointSize = sourceText.pointSize;
    app.changeGrepPreferences.pointSize = newPointSize

    target.changeGrep();

};

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 ,
Oct 19, 2023 Oct 19, 2023

Copy link to clipboard

Copied

LATEST

Or get all point sizes and change those that are greater than 15.70 and smaller than 15.71 (or whatever range).

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