Hello all! I've recently come into an odd project need whereby I need to replace large amount of unique words with a ligature to prevent unsavory words to appear when typed. My initial thought was to accomplish this using the liga feature but as a regular Glyphs user there isn't a fast 'bulk' way to add ligature feature code unless I'm just not familiar with where to look for this panel.
For fun I converted the font to TTX but I couldn't see where to add the ligature feature in an obvious way.
Rest assured I've already warned the client they need to be whole specific words rather than partial words else too many partial words would ruin longer words which contained them.
Any suggestions or insight is welcomed and appreciated! Kindly advise and thank you in advance for your time and assistance.
0
Comments
Are you familiar with the <ignore> coding?
You would have to use that, putting spaces/punctuation on either side of “shit”, for instance, to enable “mishit”. But it could get complex…
Reminds me of this.
Then you need to go into the Font Info window and select the Features tab. There you add a feature called "rlig" (as Nick suggested).
In the text view on the top right, you enter code like this:
Add one line for each word.
sub [T t] [N n] [T t] by exclam;
or more specifically if somebody uses a S or an s or an $ or a 5 in place of an s?
In feature 'rlig' ligature substitution rules cause an offset overflow (0x48bf12) to a lookup subtable
FWIW @Craig Eliason I fully agree, it's simply a path we're exploring to see what is possible and FWIW, if this thread can help somebody in the future, it's worth discussing in public.
I agree with @Craig Eliason. While this seems like a great idea, you'll be constantly chasing after all the possible variants. And what about the various letter-like symbols? Those will go to a fallback font, so any OpenType substitution won't work.
If I were to pursue this approach, though, I think what I would do is put together the full list of words that you want to process, and then a list of possible variants for each letter. And then write a python script that parses through each word and builds the substitution based on the letter variants.
So something like:
This'll output:
The problem isn't creating the substitutions but rather attempting to compile the font and not get an overflow error.
To be sure, by no means is the attached file comprehensive or even intended to be anything more than a starting point for the effort for testing but I've already got the feature code which can be added as an rlig or liga feature
Again, it just seems to be too much to allow the font to compile and I'm not sure how to specifically build this into the font as a look-up from liga or rliga and nest it in the font somewhere else.
The problem isn't creating the substitutions but rather attempting to compile the font and not get an overflow error.
Again, even though it's only 413 ligatures, I'm not sure how to specifically build this into the font as a look-up from liga or rliga and nest it in the font somewhere else.
I'm using > fontmake file.glyphs --output otf
The error is signspace is required
(Yes, this interface is terrible.)
Regardless, I'm happy to look the fool if it means we've taken this quest as far as we can and have determined it's indeed a fools errand which appears to be the case.
To be sure, at this point we have abandoned the effort due to an inability to compile as many variations as we deemed necessary into the ligature feature.
It's one thing to restrict lowercase words, another to restrict a combination of upper and lowercase words and entirely another to also consider the substitution of an $ for an S or a v for a u and with that many substitutions to consider the amount of bloat this creates makes the font simply unable to compile.
I imagine in a future version of OpenType, there may be some method that allows the embedding of a giant list of look-ups that can be packed into the font file itself without causing any compiling or speed of rendering issues for the end user. Today in 2020, not so much.
Thanks to all for their expertise and assistance!
So it sounds like you think the problem is tractable with lowercase letters but gets into overflows with uppercase and substitutions. Let’s see if there’s a clever way to get around that:
Create some empty glyphs called wascap, wasdollar, wasv etc.
Set their category to nonspacing mark.
Before your censorship lookup, use a one-to-many rule to substitute A with a wascap, B with b wascap, dollar with s wasdollar and so on.
Now comes the clever bit: in your censorship lookup, add “lookupFlag IgnoreMarks”. The was... glyphs will now be skipped over and you have reduced the character set of your search space to characters you care about, while still maintaining the information required to reconstruct the glyph string again afterwards.
Finally, add a lookup which reverses the first one, turning a wascap into A, s wasdollar into dollar and so on.
I am sure this is probably a very useful technique for some class of problem, even if this particular font doesn’t get off the ground.
sunny, glorious, sweet, and so on… however I also agree with @Craig Eliason
On the other hand, a font which replaces innocuous words with swearing would be a design concept.
So by entering the normal list as the standard ligatures should work. Fo example
Sub f l by f_l
Sub f i by f_i
My humble guess is that the overflow error comes from other place.
Maybe it is related to the letter order in each word of your list of ligatures.
I mean, maybe there is a long word that already includes one of the shorter words.
For example you may have words like "rat" and another word like "rattatuile". You get the idea? And maybe the ligature interpreterr gets confussed and explodes in the overflow error.
Make shure you detect those cases, and if you have those, they sould be in a particular order. I dont remember now if its the shorter or the longer word that must be first on the list.
You will need a script to check for that.
Hope it helps.
Im courious to see what other people think. Can this be the source of the overflow error, or I m just on too much chardonnay?
This font has 2000 lookups and can change 1800 bad words.
I made some tests and much probably this font was compiled with Microsoft VOLT.
Usually my complex fonts compilling in 2 or 3 seconds.
This fonts took 5 minutes to compile.
Take a look.
Sami
Your solutions are welcomed even though the project ended up simply abandoning this approach.