You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be really nice to be able to use ligatures in fonts like Iosevka and Fira Code with mintty.
Currently, it seems that ligatures are not displayed.
Reacted by Adrien 'Larandar' DUDOUIT-EXPOSITO, Erik Cupal, Josh Cotton, Equim, antistic, Denis Olsem, Luís, Clay Dunston, Nurettin Onur TUĞCU, Tesla Zhang and 2 more
This may be beyond the Windows API currently used for text output (ExtTextOut), see #430 and #438 (comment).
Please describe more precisely what you are missing and what you see (e.g. rendered "fl" desired to be ligature ?).
So you are not asking about any Unicode ligatures but rather font-specific ligatures.
I am not aware which Windows API, if any, would be able to handle them implicitly.
So it might be necessary to handle font information explicitly in mintty to achieve that.
You are welcome to make a proposal how to implement that.
This functionality may be available with the Uniscribe API.
Handling the complexity of that API is however beyond my current ambition to enhance mintty.
Either find any application with source code that implements this, find how it detects which character pairs have ligatures (mapping them to font glyphs).
Or find out how the TrueType cmap tables can be retrieved using the Windows API and which table contains the ligature information.
You cannot enable ligatures unless you switch from GDI to DirectWrite or FreeType.
FreeType is an external library, and DirectWrite as well as Uniscribe are of deterring complexity. I've experimented with Uniscribe, though, and it does not seem to support ligatures (so I guess notepad uses DirectWrite...).
But: The information must be available somewhere in the font file. And using a mapping table like
('-', '>', '⟶') mintty could output those glyphs by glyph index rather than character code, like it does for right-to-left text already.
@mintty Uniscribe does not support enabling arbitrary OpenType feature tag unless it is one of the “required” tags for typesetting complex scripts (like Devanagari).
@mintty To avoid some compatibility issues under Linux, Iosevka Term turned off ligatures by default.
A feature is (usually) an array of lookup indexes, indicates if this feature is enabled, which of the lookups should be set to active.
"By default" means the information is not contained in the font?
Whatever, I think I'll just close this issue unless someone enthusiastic about the feature will
demonstrate how it would be useful for at least a few fonts, and not for just 16 characters of one strange font (just look at the ugly 'm' of Fira Code!)
provide code how to retrieve a suitable mapping table from a TrueType font (starting with the GDI function GetFontData) because I'm not going to dig into the incredibly over-engineered insanity of the TrueType format myself (that person would gain a place on the mintty credits page, of course)
OK, your report was it doesn't work. As you see in your line (foo == true), it does work.
Please check the discussion above for specific combinations that are not combined into a ligature.
I might add a summary to the documentation.
oh okay @mintty sorry about that, so basically mintty has partial support of ligatures? Looking forward to the summary thanks again for the great work. 🙏🏻
I verified that "<-" is in fact handed over to Uniscribe for output in one bunch, even without that patch, actually.
Maybe some parameters to the Uniscribe functions (wintext.c) would make a difference?
Sorry for the slow response, life got in the way.
I finally got it to work! I played around with the Uniscribe parameters as you suggested, and the extra ligatures I wanted appeared when I passed in some different flags for the SCRIPT_CONTROL parameter in ScriptStringAnalyse:
SCRIPT_CONTROL sctrl;
ZeroMemory(&sctrl, sizeof(SCRIPT_CONTROL));
sctrl.fMergeNeutralItems = 1;
HRESULT hr = ScriptStringAnalyse(hdc, psz, cch, 0, -1,
// could | SSA_FIT and use `width` (from win_text) instead of MAXLONG
// to justify to monospace cell widths;
// SSA_LINK is needed for Hangul and default-size CJK
SSA_GLYPHS | SSA_FALLBACK | SSA_LINK, MAXLONG,
&sctrl, NULL, dxs, NULL, NULL, &ssa);
Is this something you would want to incorporate, or should I maintain my own fork?
Thanks for digging this out. No forks, please, I'll add that to the code. But it can only be an option, due to the ambiguity discussed before, see the marked case in the screenshot:
Any idea how to tackle this (and other?) cases?
Should it be a distinct option or a bitmask variation as Brian suggested?
Thanks for adding it as an option, I didn't want to have to keep up with all your releases.
Regarding the ambiguity, I imagine the common case of, say, '<=' is less-than-or-equal-to, not double-arrow-pointing-left. The only way I see around it is if you think it is worthwhile to write code to scan blocks, potentially break them up, and feed them to Uniscribe with different options. I suggest starting out with everything on or off, and see if many people ask for fine-grained control. FWIW, all the other programs I have tried go the less-than-or-equal-to glyph route.
For the option, you could hedge your bet about people wanting more control and have another option that is a bitmask. One bit for 'all ligatures on', and in the future other bits could be 'double-arrow-pointing-left on'.
I wouldn't know how to persuade Uniscribe to render <= as left-arrow.
The current option is about interactive line rendering support (i.e. rendering while typing), which isn't yet perfect actually.
The new option would be about the range of ligatures to enable, so a bit different - maybe it should be a separate option Ligatures then.
Activity
mintty commentedon Oct 10, 2016
This may be beyond the Windows API currently used for text output (ExtTextOut), see #430 and #438 (comment).
Please describe more precisely what you are missing and what you see (e.g. rendered "fl" desired to be ligature ?).
lf- commentedon Oct 10, 2016
Fira Code has some crazy ligatures for programming while remaining a
monospace font. -> is a ligature, so is ==.
The issue is that the raw characters are displayed and not the ligatures.
mintty commentedon Oct 10, 2016
So you are not asking about any Unicode ligatures but rather font-specific ligatures.
I am not aware which Windows API, if any, would be able to handle them implicitly.
So it might be necessary to handle font information explicitly in mintty to achieve that.
You are welcome to make a proposal how to implement that.
mintty commentedon Oct 11, 2016
This functionality may be available with the Uniscribe API.
Handling the complexity of that API is however beyond my current ambition to enhance mintty.
mintty commentedon Oct 18, 2016
So here's your homework :):
mintty commentedon Oct 20, 2016
@be5invis: taking over this issue here...
FreeType is an external library, and DirectWrite as well as Uniscribe are of deterring complexity. I've experimented with Uniscribe, though, and it does not seem to support ligatures (so I guess notepad uses DirectWrite...).
But: The information must be available somewhere in the font file. And using a mapping table like
('-', '>', '⟶') mintty could output those glyphs by glyph index rather than character code, like it does for right-to-left text already.
be5invis commentedon Oct 20, 2016
@mintty Uniscribe does not support enabling arbitrary OpenType feature tag unless it is one of the “required” tags for typesetting complex scripts (like Devanagari).
mintty commentedon Oct 20, 2016
@be5invis Thanks for the confirmation.
What about the ligature information; isn't it available as a "table" in TrueType? Any idea how to access it?
be5invis commentedon Oct 20, 2016
@mintty It’s a feature located in
GSUBtable, and it is corresponded to a list of lookups. For most programming fonts, the feature is tagged ascalt.mintty commentedon Oct 20, 2016
Hmm, using a
ttfdumptool, Iosevka doesn't seem to have anycaltentries, and Fira Code has only 16 of them, looking as mysterious as this:Probably not worth the effort...
be5invis commentedon Oct 20, 2016
@mintty To avoid some compatibility issues under Linux, Iosevka Term turned off ligatures by default.
A feature is (usually) an array of lookup indexes, indicates if this feature is enabled, which of the lookups should be set to active.
mintty commentedon Oct 20, 2016
"By default" means the information is not contained in the font?
Whatever, I think I'll just close this issue unless someone enthusiastic about the feature will
GetFontData) because I'm not going to dig into the incredibly over-engineered insanity of the TrueType format myself (that person would gain a place on the mintty credits page, of course)54 remaining items
mintty commentedon Dec 27, 2019
OK, your report was it doesn't work. As you see in your line (foo == true), it does work.
Please check the discussion above for specific combinations that are not combined into a ligature.
I might add a summary to the documentation.
chiefjester commentedon Dec 28, 2019
oh okay @mintty sorry about that, so basically
minttyhas partial support of ligatures? Looking forward to the summary thanks again for the great work. 🙏🏻scfrazer commentedon Feb 15, 2020
Sorry for the slow response, life got in the way.
I finally got it to work! I played around with the Uniscribe parameters as you suggested, and the extra ligatures I wanted appeared when I passed in some different flags for the
SCRIPT_CONTROLparameter inScriptStringAnalyse:Is this something you would want to incorporate, or should I maintain my own fork?
BrianInglis commentedon Feb 15, 2020
Add another bit setting to enable this in LigaturesSupport?
mintty commentedon Feb 16, 2020
Thanks for digging this out. No forks, please, I'll add that to the code. But it can only be an option, due to the ambiguity discussed before, see the marked case in the screenshot:

Any idea how to tackle this (and other?) cases?
Should it be a distinct option or a bitmask variation as Brian suggested?
scfrazer commentedon Feb 16, 2020
Thanks for adding it as an option, I didn't want to have to keep up with all your releases.
Regarding the ambiguity, I imagine the common case of, say, '<=' is less-than-or-equal-to, not double-arrow-pointing-left. The only way I see around it is if you think it is worthwhile to write code to scan blocks, potentially break them up, and feed them to Uniscribe with different options. I suggest starting out with everything on or off, and see if many people ask for fine-grained control. FWIW, all the other programs I have tried go the less-than-or-equal-to glyph route.
For the option, you could hedge your bet about people wanting more control and have another option that is a bitmask. One bit for 'all ligatures on', and in the future other bits could be 'double-arrow-pointing-left on'.
mintty commentedon Feb 16, 2020
I wouldn't know how to persuade Uniscribe to render <= as left-arrow.
The current option is about interactive line rendering support (i.e. rendering while typing), which isn't yet perfect actually.
The new option would be about the range of ligatures to enable, so a bit different - maybe it should be a separate option
Ligaturesthen.support enabling of additional ligatures such as arrows (#601)
fix placement of ligatures options in manual page (~#601)
mintty commentedon Feb 25, 2020
Released 3.1.4.
mintty commentedon Feb 25, 2020
There is a bug with crash potential in the wslbridge gateway. Waiting for its fix.
wintext: with Ligatures=0, render plain-ASCII runs via ExtTextOutW