Comments (8)
I think I've mastered the contextual substitutions!
Fira Code actually does some really funky stuff to support both caret position as well as ensuring ligatures don't repeat undesirably.
Basically it uses a feature in OpenType call contextual substitutions. You create a table with backtrack, input, and lookahead glyphs to tell the renderer which glyph to ultimately use. What Fira Codes does is replace the component glyphs of the ligature into LIG
(placeholder) glyphs. Once it has chained enough of those placeholders, does it output the actual ligature glyph. It also checks to see if you are repeating the start or end of ligatures and prevents the ligature replacement from occurring. This way if you have a chain of =, +, or -, the ligatures won't occur since it's no longer stand alone.
Here's the table for the <!--
ligature. B2-B0 are the backtrack glyphs, IN is the current input, and L0-L3 are the lookahead glyphs. You can see how the first 2 rows check for repeating glyphs that would cause the ligature to be skipped.
The rest are simply the placeholder LIG
s that are built up until you get enough to output the actual ligature. As you can see, this follows a predictable pattern, so I wrote some code that will generate these tables automatically for any given ligature.
B2 | B1 | B0 | IN | L0 | L1 | L2 | L3 | Subst |
---|---|---|---|---|---|---|---|---|
< | < | ! | - | - | skip | |||
< | ! | - | - | - | skip | |||
LIG | LIG | LIG | - | less_exclam_hyphen_hyphen.liga | ||||
LIG | LIG | - | - | LIG | ||||
LIG | ! | - | - | LIG | ||||
< | ! | - | - | LIG |
I'm hoping to have a test version of the new font done this weekend. I'll let you know when you can check it out.
Thanks!
from operator-mono-lig.
The context aware feature has been pushed to the features/contextsubst branch. The ligature will no longer repeat once you exceed a vaild ligature. It will simply revert to the individual characters.
from operator-mono-lig.
I did notice this as well, every two dash's get lumped together, but do not touch.
from operator-mono-lig.
Yes, this is a known "issue". This is basically the hyphen_hyphen ligature (--). Ligatures are not context aware. Therefore anytime there are 2 hyphens, it will display the ligature.
Now as in the carat spacing issue #35, Fira Code obviously uses some advance OpenType features to handle this. Unfortunately, I'm not very experienced with this, so not sure where to make the changes. Again, if there are OpenType experts out there, please feel free to point me in the right direction.
Thanks!
from operator-mono-lig.
I think the following might allow us to fix this. I'm just not sure how to do it yet. :P
Conditional Features. OpenType and Apple fonts both provide contextual features. These are features which only take place in a given context and are essential for typesetting Indic and Arabic scripts. In OpenType a context is specified by a set of patterns that are tested against the glyph stream of a document.
Contextual features - FontForge
https://fontforge.github.io/editexample6-5.html
I've been doing a bit of practice with FontForge over the last little while, but I'm not sure yet how to do this. I keep reading little snippets about contextual regex options being available in OpenType. But it's all way down the list of things to figure out for me right now.
Note: the above link is for the old fontforge. I'm not sure if it's 100% relatable to the newer versions. I included it as a reference point for what to look for in either application.
from operator-mono-lig.
I ordered this book: Fonts & Encodings
It has a section on substitution tables that hopefully will point me in the right direction.
See Search result
from operator-mono-lig.
@kiliman freat news! Looking forward this update.
Thanks for the hard work!
from operator-mono-lig.
@kiliman I'm up for testing as well if you need an extra set of eyes!
from operator-mono-lig.
Related Issues (20)
- Build fails in Big Sur HOT 6
- Erro on VSCODE - letter spacing 0? HOT 12
- Operator Mono SSm Lig Book does not work with Vscode HOT 9
- Build script doesn't do anything HOT 6
- Ligatures Not Working HOT 16
- some ligatures dont work in italics. HOT 4
- build doesn't do anything HOT 10
- Create ligatures for `Operator Mono Bold` HOT 2
- Running ./build.sh just create build folder with empty HOT 10
- Glyphs are way too small HOT 3
- npm install always giving errors HOT 3
- Not an issue: meant to help to use Win 10 Npm problems HOT 2
- Create `::` ligature HOT 10
- Cannot run npm install node-pre-gyp ERR! build error HOT 2
- Got a lot of errors after npm install. (Windows 11) HOT 6
- Only two fonts in build folder HOT 6
- Does not work with Python 2.7 shipped with MacOS Montery HOT 1
- The following glyph names are referenced but are missing from the glyph set: underscore.alt HOT 1
- If you get error after error!
- Copyright to matter about? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from operator-mono-lig.