You are not logged in.

#1 2018-07-14 23:07:01

cuteclown
Guest

[Solved] Disabling ligatures in monospace font

For a while, I have noticed a strange thing when using geany as a text editor: Certain combinations of letters (like 'ff', and 'fi') seem to combine into a single character. This is very distracting, and messes up the spacing (since it breaks the whole premise of a monospace font). Appearently, this combining of two letters into a single one is called a 'ligature', and they are very cool. I don't understand why this seemed a good idea in the first place, but OK.

Is there a way to disable ligatures? I am not sure where to look. xfce4-terminal does not use them. I couldn't find anything in the xfce settings, and googling didn't help much either.

Edit: For future reference: Apparently, the Nimbus Mono font contains ligatures (which is unusual for a monospace font, I guess?). AFAIK, the rendering of these can't be disabled - I solved the issue by switching to another font (DejaVu Sans, which can be found in the ttf-dejavu package).

Last edited by cuteclown (2018-07-15 13:24:10)

#2 2018-07-14 23:48:50

circleface
Member
Registered: 2012-05-26
Posts: 639

Re: [Solved] Disabling ligatures in monospace font

That sounds more like a font issue, but it is certainly strange and I have never run into it.  Which monospace font is doing this for you, or is it all of them?  I use the DejaVu fonts and it seems to work fine here.

Offline

#3 2018-07-15 00:16:02

cuteclown
Guest

Re: [Solved] Disabling ligatures in monospace font

circleface wrote:

That sounds more like a font issue, but it is certainly strange and I have never run into it.  Which monospace font is doing this for you, or is it all of them?  I use the DejaVu fonts and it seems to work fine here.

I was getting the impression that it was intended behavior and I was getting old and grumpy for not liking it, but I am glad that you find it as strange as I do.
I see the same behavior for all fonts (I first noticed it for Monospace Regular, 10pt). Of course it is especially noticeable for monospace fonts.

#4 2018-07-15 01:38:47

circleface
Member
Registered: 2012-05-26
Posts: 639

Re: [Solved] Disabling ligatures in monospace font

What does

fc-match monospace

return for you.  For me, it is

DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

My geany config also has "monospace regular 10pt." as the font, and I'm not seeing any of these character overlaps or ligatures.

Offline

#5 2018-07-15 02:05:14

Oxyd
Member
From: Czech Republic
Registered: 2008-01-17
Posts: 167

Re: [Solved] Disabling ligatures in monospace font

Does it convert text to ligatures as you type it in, or do you only see them in other files that you open? By saying that xfce4-terminal does not use them, do you mean that when you view the same file you were editing in Geany in xfce4-terminal, it doesn't render with ligatures?

Offline

#6 2018-07-15 07:32:45

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: [Solved] Disabling ligatures in monospace font

Auto-replacing a double letter w/ a ligature is a complete crap behavior for a text-editor.
This is not a rendering thing: the ligature is ONE character, different from the TWO characters you entered. Your input is literally replace with something else.

if (token == "effort")

is not the same as

if (token == "effort")

despite it might even look the same (in variable width fonts)
The reason why this breaks glyph widths is that most monospace fonts do not provide ligatures (consolas being a prominent exception)

Unless this is done by some input method (https://wiki.archlinux.org/index.php/Lo … ut_methods), look out for an autocorrection config in geany and if it's not configurable or even just active by default: get a sane editor.
This behavior is close to malware. Next it flips in cyrillic or other homgraphs…

Offline

#7 2018-07-15 07:35:53

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: [Solved] Disabling ligatures in monospace font

[double post, bbs 504'd on me!]

Last edited by seth (2018-07-15 07:36:28)

Offline

#8 2018-07-15 13:18:42

cuteclown
Guest

Re: [Solved] Disabling ligatures in monospace font

circleface wrote:

What does

fc-match monospace

return for you.  For me, it is

DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

Haha, I'm sorry you have to specify everything down to the command for me wink

cuteclown@T410 » fc-match monospace                                                  ~
NimbusMonoPS-Regular.otf: "Nimbus Mono PS" "Regular"

Does it convert text to ligatures as you type it in, or do you only see them in other files that you open? By saying that xfce4-terminal does not use them, do you mean that when you view the same file you were editing in Geany in xfce4-terminal, it doesn't render with ligatures?

This is not a rendering thing: the ligature is ONE character, different from the TWO characters you entered. Your input is literally replace with something else.

I was not aware that ligatures have their own character codes. My first post was not accurate - I see this behavior in the browser as well (I just didn't notice it before because I normally don't read monospace text in the the browser). In seth's post I see the ligature (assuming that is indeed the right term for the behavior I'm seeing) as well, on *both* quotes: mj649CRl.png
I also don't see ligatures in geany on my other system, where I use DejaVu Sans. So maybe it is a font issue after all...

Furthermore, the input is not getting replaced by the ligature - it is only shown as a ligature (but they are converted on-the-fly while I am typing). It seems to be a rendering issue instead of an issue in geany. Evidence to support this: If save some character combinations that get rendered as ligatures (ff, fl, fi, ae, for example) in geany to a file, and open it in vim (or gvim), I don't see the ligatures anymore.

Sorry for the confusion!

Edit: I installed the ttf-dejavu package and I no longer see ligatures! smile I have marked the thread as solved, but I'm still curious if there is an explanation for this behavior.

Last edited by cuteclown (2018-07-15 13:21:09)

#9 2018-07-15 14:08:01

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: [Solved] Disabling ligatures in monospace font

https://en.wikipedia.org/wiki/Kerning

I just tried and can reproduce this w/ Nimbus Mono PS in eg. scite.
You're right in that it's not the editor and indeed a rendering (or rather a font) issue, though this kind of kerning definition in a *monospace* font is nuts. The entire point about a monospace font is the monotonic font width… m(

Edit:
No loss - "1" looks like "l" and "0" isn't slashed or dotted and looks like "O" - those are epic fails for a (coding centric) monospace font anyway. So just be happy using about almost every other monospace font ;-)

Last edited by seth (2018-07-15 14:11:50)

Offline

#10 2018-10-01 01:06:24

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 190
Website

Re: [Solved] Disabling ligatures in monospace font

Finally decided to try to fix this myself.  There are two solutions - one is to disable ligatures for the font in question, which unfortunately only works for some programs and not others (mainly it doesn't work for Firefox).  The second option is to simply replace the ligatured font with another, which does work for Firefox.

I documented my solution on the wiki so that it can be kept up to date if anything changes in future.

Offline

Board footer

Powered by FluxBB