Skip to content

Ligature support #2287

Closed
Closed
@Graucsh

Description

@Graucsh

Description of the Issue

Fonts that support ligatures are not drawn with them

Steps to Reproduce the Issue

  1. Select a font that supports ligatures, such as Fira Code
  2. Select a C-based language
  3. key in "!="

Expected Behavior

a long equals sign with a slash through it

Actual Behavior

discrete characters

Suggestion

Set the Technology property of the Scintilla objects to DirectWrite, which draws with ligatures, or provide an option to turn it on.

default
directwrite

Activity

dail8859

dail8859 commented on Sep 15, 2016

@dail8859
Contributor

Duplicate of #1651

I looked into this at one point and just using SC_TECHNOLOGY_DIRECTWRITE is not enough. Notepad++ uses Scintilla v3.5.6 and it seems that a newer version of Scintilla is required to support ligatures. So once Scintilla is updated internally this will most likely be possible.

Graucsh

Graucsh commented on Oct 24, 2016

@Graucsh
Author

I added the following line to void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose):
::SendMessage(viewToOpen->getHSelf(), SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITE, 0);

I realize that's probably not the right place, but I got the following result using the Fira Code font:

npp_ligatures

dail8859

dail8859 commented on Oct 24, 2016

@dail8859
Contributor

That's interesting. I tried the exact same thing before without any success. Though I tried it on Win7 which might be a difference.

Graucsh

Graucsh commented on Oct 25, 2016

@Graucsh
Author

Maybe it makes a difference where the message is sent?
npp_ligatures_win7

I put the code after:
MainFileManager->addBufferReference(id, viewToOpen);

dail8859

dail8859 commented on Oct 25, 2016

@dail8859
Contributor

This is what I tried:

  • Install the Fira Code font (I think I used the medium)
  • Set the global Notepad++ font to use Fira Code
  • Type something like != and nothing happens. (I can see the font is getting changed, it just doesn't seem to pick up on the character sequences at all.)

Can't remember where I put that call in that function, but I'll try exactly where you said and see if that works for me.

Graucsh

Graucsh commented on Oct 25, 2016

@Graucsh
Author

I can confirm your results. Only Fira Code and Fira Code Retina draw with ligatures. Light and Medium do not.

dail8859

dail8859 commented on Oct 25, 2016

@dail8859
Contributor

Success!

capture

I found I had all the different fonts installed but none of them worked...however I installed them a while ago so I downloaded and installed the latest version of the regular Fira Code font and it worked perfectly.

On a side note I don't think it matters when SCI_SETTECHNOLOGY is set because I manually changed it by my scripting plugin while a file was already opened and it immediately worked. :)

Graucsh

Graucsh commented on Oct 25, 2016

@Graucsh
Author

Fantastic! Thanks for staying with me on this. I really appreciate it!

dail8859

dail8859 commented on Oct 25, 2016

@dail8859
Contributor

Only Fira Code and Fira Code Retina draw with ligatures. Light and Medium do not.

Is this something you discovered yourself or is it documented somewhere?

Graucsh

Graucsh commented on Oct 25, 2016

@Graucsh
Author

Discovered with your help. I just put a != in the editor and flipped through the 4 variants. Your mentioning that you tried the medium got me to thinking.

It may be worth noting that Windows Notepad only lists the regular and retina. However, the Windows font previewer seems to like them all.

mmokross

mmokross commented on Oct 27, 2016

@mmokross

Hmmm... sorry but maybe I'm confused: should this work right now on Windows 10 with Notepad++ v7.1, 32bit, build from Oct 15 2016? Or do I have to wait for an update?

dail8859

dail8859 commented on Oct 27, 2016

@dail8859
Contributor

It won't currently work "out of the box". The text rendering needs tweaked but you can do it with a plugin. Keep in mind support for ligatures is not officially supported so you might run into issues.

This is the easiest way I know (without recompiling) to get ligatures to work in Notepad++:

  1. Install a recent version of Fira Code (use either the normal font or the retina as those are the only ones that seem to work).
  2. Install LuaScript via the Plugin Manager (you can also use PythonScript if you are more comfortable with it or want to use a 10 ton hammer).
  3. Select the font via Settings > Style Configurator > Global Styles > Global Override. Select "Fira Code" for the font style and turn on Enable global font
  4. Edit the LuaScript startup file by doing Plugins > LuaScript > Edit Startup Script and add the following code:
editor1.Technology = SC_TECHNOLOGY_DIRECTWRITE
editor2.Technology = SC_TECHNOLOGY_DIRECTWRITE

Restart and enjoy.

mmokross

mmokross commented on Oct 27, 2016

@mmokross

Thanks! Worked like a charm!

limingjie

limingjie commented on Dec 7, 2016

@limingjie

@dail8859 After using the workaround, font Iosevka works, but Iosevka Light not.

48 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedfeatureFeature requests and Feature commits

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @donho@treyharris@KOLANICH@sigzero@u01jmg3

      Issue actions

        Ligature support · Issue #2287 · notepad-plus-plus/notepad-plus-plus