Skip to main content
Inspiring
August 3, 2026
Answered

Find a glyph based on the glyphs next to it

  • August 3, 2026
  • 7 replies
  • 48 views

I want to find all instances of the glyph (with unicode value \x{f067}) which appears before and after glyphs that have a red character style.

I want to apply a character style to it

    Correct answer Peter Kahrel

    @Summayah5FC7 Seems to me that this should work:

    1. Apply the character style ‘red’ to all red text.

    2. Apply the red honorific style to all the red honorific characters.

    3. Apply the honorific style to all black honorific characters.

    But to fix text that you already processed (or just in case the solution doesn’t work), here’s a script:

    (function () {
    var red = app.documents[0].characterStyles.item('red');
    var honorific = app.documents[0].characterStyles.item('red honorific');

    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = /.\h\x{f067}\h./.source;
    var found = app.documents[0].findGrep();
    for (var i = 0; i < found.length; i++) {
    if (found[i].characters[0].appliedCharacterStyle === red
    && found[i].characters[-1].appliedCharacterStyle === red) {
    found[i].characters[2].appliedCharacterStyle = honorific;
    }
    }
    }());

     

    7 replies

    Inspiring
    August 5, 2026

    Thanks

    Community Expert
    August 4, 2026

    This can be done with a script - I have something similar - can you share a document with me for testing please? 

    Thanks

    Peter Kahrel
    Community Expert
    Community Expert
    August 4, 2026

    Those glyphs themselves are not in the red character style?

    Inspiring
    August 4, 2026

    No because it is a different font to the paragraph

    Peter Kahrel
    Community Expert
    Community Expert
    August 4, 2026

    Ok. You wrote “before and after glyphs that have a red character style.” Is that a real character style or some locally applied colour? If it’s a style, what is its name? And what is the name of the style you want to apply to the glyph?