# Substitute one glyph with another if space on both sides?

**URL:** <https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414>\
**Category:** Scripting\
**Created:** [July 13, 2012, 3:40pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414 "2012-07-13T15:40:47Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Musgrapha](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/m/41988e/32.png) [@Musgrapha](https://forum.glyphsapp.com/u/Musgrapha)\
**Post date:** [July 13, 2012, 3:40pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/1 "2012-07-13T15:40:47Z")

</div>

I’m creating an all-caps comics font, where you usually want to substitute the “I” noun with a crossbar-I. I don’t want the font to substitute all I’s (for example, within any word) with a crossbar-I, only the ones that have spaces on both sides of them.

How would I accomplish this? I know that one way would be to use the lower case i as the crossbar-I, but i’d rather make it easier for the letterer to just have it appear in this certain circumstance.

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [July 13, 2012, 5:37pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/2 "2012-07-13T17:37:19Z")

</div>

You would add a “calt” feature and put in

sub space I’ space by I.crossbar;

But be careful, this would not work at the end or beginning of the line or if there is a punctuation mark next to it.

---

<div class="post-metadata">

**Author:** ![mekkablue](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mekkablue/32/23_2.png) [@mekkablue](https://forum.glyphsapp.com/u/mekkablue)\
**Post date:** [July 13, 2012, 10:33pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/3 "2012-07-13T22:33:33Z")

</div>

Well, in that case, do it the other way around. Make the crossbar version the standard and substitute it with the other I in the opposite circumstances.

---

<div class="post-metadata">

**Author:** ![Musgrapha](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/m/41988e/32.png) [@Musgrapha](https://forum.glyphsapp.com/u/Musgrapha)\
**Post date:** [July 14, 2012, 4:37am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/4 "2012-07-14T04:37:23Z")

</div>

Thanks for the replies!

The crossbar-I should present itself instead of the normal I in the following combos:

I  
I’ve  
I’m

As Georg wisely noted, I should also be replaced with crossbar-I in the following cases:

I.  
I’ve.  
I’m.  
I,  
I’ve,  
I’m,

Even though I think these are rare situations.

I guess the answer would be to create a different calt feature for every one of these circumstances.

I tried creating a calt feature as you instructed but I keep getting an error message.

Please keep in mind that I’m a beginner-level user and haven’t done any programming or opentype coding perviously, so unfortunately you have to be very precise and ground-up with your instructions…

Where exactly should I place the calt feature? I know it’s not under dlig, as the ligature code.

is this all the code I need (for one substitution):

sub space i’ space by space crossbar\_i space;

or should it be a longer form (found in adobe’s source):

feature calt {  
sub space i’ space by space crossbar\_i space;  
} calt;

or something else?

Mekkablue: I’m not sure how that would work? I would still have to create conditions to the substitutions, only this time the other way around…

Kind regards and thanks for your patience!

---

<div class="post-metadata">

**Author:** ![DTF](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/d/dfb087/32.png) [@DTF](https://forum.glyphsapp.com/u/DTF)\
**Post date:** [July 14, 2012, 2:49pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/5 "2012-07-14T14:49:12Z")

</div>

_I guess the answer would be to create a different calt feature for every one of these circumstances._

You only need one feature, with a rule for each circumstance.

_I tried creating a calt feature as you instructed but I keep getting an error message._

Post the error.

_Where exactly should I place the calt feature? I know it’s not under dlig, as the ligature code._

CALT should be on its own, not inside of another feature.

When coding OT it helps to just add one line at a time and compile each one as you go. This is much faster than debugging once you have a hundred+ lines of code.

_is this all the code I need (for one substitution):_

Create a CALT feature in the feature editor and just paste in your substitution code. You don’t need to declare the beginning and end of each feature (feature calt {) in Glyphs, it does that for you.

---

<div class="post-metadata">

**Author:** ![eliason](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/eliason/32/269_2.png) [@eliason](https://forum.glyphsapp.com/u/eliason)\
**Post date:** [July 14, 2012, 6:25pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/6 "2012-07-14T18:25:18Z")

</div>

Rules can also have multiple options in brackets: for example,

sub I’ [space apostrophe comma period] by I.crossbar;

would change out the I when followed by any of those listed glyphs.

---

<div class="post-metadata">

**Author:** ![Musgrapha](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/m/41988e/32.png) [@Musgrapha](https://forum.glyphsapp.com/u/Musgrapha)\
**Post date:** [July 15, 2012, 10:00am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/7 "2012-07-15T10:00:01Z")

</div>

Hey, thanks for your advice!

I started simple and tried:

sub i’ by crossbar.i;

which worked as expected, replacing every i with a crossbar.i

I then tried to change every “i’m” to “I’m” by

sub i quotesingle m’ by crossbar.i quotesingle m;

but that produces the following error:

Error: “Unsupported contextual GSUB replacement sequence” in Feature calt in line: 1  
No File was created.

I tried looking for examples of similar substitutions online so I could see how to write the sequence correctly but couldn’t find any…

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [July 15, 2012, 7:51pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/8 "2012-07-15T19:51:02Z")

</div>

you can only substitute one glyph by one other glyph. And if you use the context substitution (with the single quote) you can substitute the glyph that is marked with the quote.

So you write:  
sub i’ quotesingle m by crossbar.i;

So you mark the i for substitution if it is before a quotesingle and a m.

---

<div class="post-metadata">

**Author:** ![Musgrapha](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/m/41988e/32.png) [@Musgrapha](https://forum.glyphsapp.com/u/Musgrapha)\
**Post date:** [July 16, 2012, 7:00pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/9 "2012-07-16T19:00:59Z")

</div>

Once again, thanks for the great advice. Feel like I’m starting to get the hang of this with your help.

I’ve created several ligatures now, which are replaced in situations where the crossbar.i is needed. The only situation I haven’t so far been able to figure out is when the noun “I” starts a sentence. Can you think of any way to detect whether or not there’s a glyph before it?

---

<div class="post-metadata">

**Author:** ![reitermarkus](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/reitermarkus/32/91_2.png) [@reitermarkus](https://forum.glyphsapp.com/u/reitermarkus)\
**Post date:** [July 20, 2012, 7:57pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/10 "2012-07-20T19:57:00Z")

</div>

The only way I could think of would be creating a class containing all glyphs (except space) and substitute it with this class.

sub @allglyphs I’ by crossbar.i;

Does anyone know a better way?

---

<div class="post-metadata">

**Author:** ![mekkablue](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mekkablue/32/23_2.png) [@mekkablue](https://forum.glyphsapp.com/u/mekkablue)\
**Post date:** [July 21, 2012, 7:36am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/11 "2012-07-21T07:36:40Z")

</div>

> [@](#):
>
> The only way I could think of would be creating a class containing all glyphs (except space) and substitute it with this class.
> 
> sub @allglyphs I’ by crossbar.i;

What do you want to do? This would substitute the I every time it follows another letter. This, I believe, was not the original purpose. What I suggested (and perhaps what you mean) is something like this:

lookup ISUB {  
ignore sub @ALLGLYPHS I’, I’ @ALLGLYPHS;  
sub I by I.crossbar;  
} ISUB;

I put it inside a lookup, so the ignore line will not apply to anything that comes later. It may have a few other consequences though, so you may want to place it at the end of your feature. The solution assumes you have all relevant letters in a class called ALLGLYPHS. The ignore line means: ignore the case of a preceding letter, and ignore the case of a letter coming right after the I. But other than that, substitute every I by I.crossbar.

---

<div class="post-metadata">

**Author:** ![Avantino](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Avantino](https://forum.glyphsapp.com/u/Avantino)\
**Post date:** [May 24, 2016, 8:26am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/12 "2016-05-24T08:26:23Z")

</div>

In a different aspect;  
Wondering if it is possible to assign different {space}s for each script in a multi-script typeface?  
i.e a Latin-Hebrew-Cyrillic would have two space at least?

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [May 24, 2016, 8:36am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/13 "2016-05-24T08:36:08Z")

</div>

You can do that. Add it to the `locl` feature like this:

```auto
script cyrl;
sub space by space.loclCYL;

```

---

<div class="post-metadata">

**Author:** ![jessemlahn](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/jessemlahn/32/29223_2.png) [@jessemlahn](https://forum.glyphsapp.com/u/jessemlahn)\
**Post date:** [March 26, 2026, 1:54am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/14 "2026-03-26T01:54:22Z")

</div>

I’ve been trying to do this, but I’m not having any luck.

I created a new glyph “space.loclHB” and assigned it a Unicode value of E0000.

 ![Screenshot 2026-03-25 at 9.40.22 PM](https://forum.glyphsapp.com/uploads/default/original/3X/b/a/ba7260ab85fa53a67997f23d43042d589f230989.png)

Then I added these lines in the Localized Forms feature:

_ **script** hebr;  
 **sub** space **by** space.loclHB;_

I also made sure that I added Hebrew to “Languagesystems”.

 ![Screenshot 2026-03-25 at 9.46.05 PM](https://forum.glyphsapp.com/uploads/default/original/3X/4/6/467d53669947b19fbf8eba87c99591ac14530106.jpeg)

 ![Screenshot 2026-03-25 at 9.40.09 PM](https://forum.glyphsapp.com/uploads/default/original/3X/5/9/59682308bf9ce037ee2cf48c1488b8e638458c89.jpeg)

When I export the font, the substitution does not work (in InDesign with the Language set to Hebrew). If I assign the Language as any other than Hebrew, it works.

I tried making a secondary GlyphData.xml file, per the instructions ( [Roll your own glyph data | Glyphs](https://glyphsapp.com/learn/roll-your-own-glyph-data) ). However, when I restart Glyphs, I get an error stating the custom file is empty.

 ![Screenshot 2026-03-25 at 9.41.15 PM](https://forum.glyphsapp.com/uploads/default/original/3X/5/7/571bd142f3fd511ac9b1286506a77d826577df3a.jpeg)

 ![Screenshot 2026-03-25 at 9.42.04 PM](https://forum.glyphsapp.com/uploads/default/original/3X/0/e/0efb8c8cc3145237d575a06ef80f758a074eedfa.png)

Anyone know what I’ve done wrong‽

---

<div class="post-metadata">

**Author:** ![FlorianPircher](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/florianpircher/32/30457_2.png) [@FlorianPircher](https://forum.glyphsapp.com/u/FlorianPircher)\
**Post date:** [March 26, 2026, 8:36am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/15 "2026-03-26T08:36:26Z")

</div>

Some of the code uses curly quotes like “ and ” but in code only the simple " quote is valid.

---

<div class="post-metadata">

**Author:** ![SCarewe](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/scarewe/32/18952_2.png) [@SCarewe](https://forum.glyphsapp.com/u/SCarewe)\
**Post date:** [March 26, 2026, 10:10am UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/16 "2026-03-26T10:10:57Z")

</div>

What Florian said. I would strongly recommend using an actual code editor (Sublime Text is great, for example), which doesn’t enable smart quotes.

There is also [EditGlyphData](https://glyphsapp.com/tools/editglyphdata), a dedicated tool.

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [March 26, 2026, 3:44pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/17 "2026-03-26T15:44:47Z")

</div>

The GlyphData.xml file needs to be a plain text file. Yours seems to be a formatted file. Do Format \> Make plain text.

But, you don’t need the .xml file for what you are trying to do. You can just set the values directly (Edit \> Info for Selection).

You should use `space.loclIWR`. Then automate the feature code.

BUT: substituting the space glyph doesn’t often work in Indesign. So test in FontGoggles to see if the OpenType works. If it then doesn’t work in Adobe apps, then you are out of luck.

---

<div class="post-metadata">

**Author:** ![jessemlahn](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/jessemlahn/32/29223_2.png) [@jessemlahn](https://forum.glyphsapp.com/u/jessemlahn)\
**Post date:** [March 26, 2026, 6:14pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/18 "2026-03-26T18:14:05Z")

</div>

It’s InDesign! FontGoggles got the code right.

I’ll try some other options to force InDesign to make the space greater in the Hebrew.

Thanks for everyone’s patience and help!

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [March 26, 2026, 6:41pm UTC](https://forum.glyphsapp.com/t/substitute-one-glyph-with-another-if-space-on-both-sides/414/19 "2026-03-26T18:41:54Z")

</div>

You might be able to use GPOS. Meaning kerning of space with all Hebrew letters.
