Replacing glyphs with each other

In OpenType features, there is a replacement of one glyph for one glyph (GSUB1), one glyph for two glyphs (GSUB2), and two glyphs for one glyph (GSUB4). But there is no definition for replacing two glyphs for two glyphs.
I have several glyphs that I want to replace with each other, for example, I want every time “Hello” to be written, the second letter “l” to be replaced with the letter “o”, and it will be written “Helol”, why? This is just an example, but I have some important uses in my language (like correcting a typo of a space before a comma " ," which will be automatically corrected to ", ").
I have a few ways that I have noticed that work, but before I write, I would like to know from the experts here in the group which way works for you and which is the most recommended.

There is no specific lookup type for this, but you can do it with two or more lookups.

That said, it is strongly discouraged to use OpenType layout features to fix spelling, as that should be done at a higher level, like a spellings checker.

I know. I brought the example of spelling correction just for example, my need must be built into the font.
I tried to write the problem but it was written unclearly.
How do you think this could work?

One way to accomplish this is to first replace several glyphs with a single (unmapped) glyph, using a ligature substitution. Then use a mulitple substitution lookup, (also known as decompose) to replace the ligature back into the final glyphs.

If you only want to make this happen if the text is preceded by a letter “p”, then use the ligature within a contextual substitution.

languagesystem latn dflt; # Latin default

lookup Ligature1 { # GSUB lookup type Ligature
    sub m q by mult2multi;
} Ligature1;

feature liga { # Standard Ligatures
    lookup ChainingContext1 { # GSUB lookup type ChainingContext
        sub p m' lookup Ligature1 q';
    } ChainingContext1;

    lookup MultipleSubstitution1 { # GSUB lookup type MultipleSubstitution
        sub mult2multi by q m;
    } MultipleSubstitution1;
} liga;

Indeed, this is one of the ways I learned at the beginning.

For the benefit of all users, I will upload here a few optional ways, the last way is the way that pleased me the most and in my opinion is the most correct way, so I will write it last..
For the benefit of everyone, I also uploaded a font file (Calibri) with all the ways that can be changed, each of the ways is in a different stylistic set.
The number 1 was replaced with a simple mark that I invented for this experiment. The rest of the glyphs were deleted.
In the Preview panel, type the following words:
Hello Hell1o1 Food

Link to files
Link to files

  1. Replace with one and replace with two:
    1.1. Replace both glyphs with one invented glyph (it doesn’t even require Unicode, just a glyph that was added just for the purpose of replacement).
    1.2. Replace this glyph with two glyphs.
    Advantages - Easy and simple way, familiar and always works.
    Disadvantages - Does not preserve marks that were on the first glyph, requires adding an unnecessary glyph..

  2. Creating a ligature glyph:
    2.1. A glyph with the reversed letters must be added.
    2.2. The pair of letters must be searched for and replaced with this glyph.
    Advantages - No need for much programming.
    Disadvantages - Does not preserve marks that were on the first glyph, requires adding an unnecessary glyph, defines this pair of glyphs as a ligature

  3. Chaining Context with two conditions:
    3.1. Chaining Context must be added and the first glyph must be written in Input, and the second glyph must be written in Lookahead.
    3.2. Add (outside the script) two Single Substitution lookups, in the first - replace the first glyph with the second, and in the second - replace the second glyph with the first.
    3.3. In the Substitution Tables field, add Single Substitution1.
    3.4. In Chaining Context add Rule 2, in Input write the second glyph, and in Backtrack write the second glyph (! For some reason, you have to write both).
    3.5. In the Substitution Tables field add Single Substitution2.
    Advantages - This method replaces the first with the second and the second with the first, you can easily add a condition in Backtrack and Lookahead, preserving the marks that were on the first.
    Disadvantages - It also replaces the times when the second glyph appears twice, which is a notable disadvantage.

  4. Real replacement of the glyphs with each other:
    4.1. Add Chaining Context and in Input write the two glyphs.
    4.2. Add (outside the script) two Single Substitution lookups, in the first - replace the first glyph with the second, and in the second - replace the second glyph with the first.
    4.3. In the Chaining Context lookup, in the Substitution Tables field write both lookups.
    4.4 Check Single Substitution2, and thicken the Sequence Index field to 1.
    Advantages - This method really replaces the first with the second and the second with the first, you can easily add a condition in Backtrack and Lookahead, keeps the marks that were on the first
    Disadvantages - I didn’t find…

By the way, pay attention to the Ignore Marks check in all lookups.

Link to files
Link to files

I would love to hear user opinions, have you encountered this problem? Did I help you with this solution? Am I right?
Interesting to know.