source-foundry / Hack

A typeface designed for source code
http://sourcefoundry.org/hack/
Other
16.52k stars 613 forks source link

Hasklig style ligatures #35

Open i-am-the-slime opened 9 years ago

i-am-the-slime commented 9 years ago

This'd be so cool: https://github.com/i-tu/Hasklig

metaskills commented 9 years ago

Agreed, was the first thing I looked for in this project.

GauthierPLM commented 9 years ago

I'm looking for that too. But not only for Haskell related ligatures (a big part of Hasklig ligatures are Haskell specifics), but for more general programming ligatures as available in FiraCode who have a lot of ligatures available, and a big part of them are common programming symbols.

chrissimpkins commented 9 years ago

For those who aren't aware of ligatures in source code typefaces, see the Fira Code site which has a nice set of images that show the ligatures compared to the actual glyph combinations.

I have been torn on the standard ligature issue. While it works very well in circumstances when you are working in an editor with the typeface and know that the ligatures are present, it misinforms readers when the typeface is used to display source code to others (print, websites, presentations, embedded in pdf's, embedded in applications). You can imagine a scenario where a developer who is new to a language attempts to use a Unicode leftwards arrow rather than a < adjacent to a - because that is the way that it was displayed in the location where they learned it. In these cases, the type interferes with the message. IMO, this limits the scope of a font with standard source code idiom/char combination ligatures and my goal is to maintain the main branch of Hack as a general use face for source (including display and embedding).

The OpenType discretionary ligature feature (off by default, explicitly activated) would be ideal, but it isn't supported by any desktop source code editor to my knowledge so it would not address your request. On the web side, the CSS3 spec includes support for them, but I do not believe that this is widely supported by browsers at the moment either. This does not appear to be a good approach for now.

This would be a great feature for a working font designed for a select group of developers and I think it would warrant a separate build from the general purpose main branch of Hack to support it.

My understanding from the Fira Code and Hasklig documentation is that standard ligature support is spotty at best across current versions of commonly used text editors. I guess this begs the question whether this is worth the effort until that situation changes.

GauthierPLM commented 9 years ago

For editors in Java (like IntelliJ), the OpenJDK have a bug who prevents from rendering ligatures. An issue on the JetBrains bug tracker (https://youtrack.jetbrains.com/issue/IDEA-127539) have been opened to support ligatures into the IDE and a guy from JetBrains has reported the bug to the JDK team. If it's solved, we can hope that IntelliJ and others IDE in Java should support Ligature.

Currently, I only know 3 OS fonts who provide ligatures for coding + Pragma Pro. It could be a good feature in your font, especially because it's a coding font. Having a separated branch is a good idea or the possibility to customize the font (as with Monoid) could be a good idea, with a warning to suggest users to not use ligatures in their articles.

alerque commented 9 years ago

@chrissimpkins I agree pretty much tit for tat with your analysis here. This can be great for somebody that know exactly what was going on but is a probable source of trouble for anybody unfamiliar with both the programming language and the font features involved. In other worse it would be nice to have but only in the context of an off-by-default feature.

The only thing I can really add is that browser support for CSS3 features that enable alternate ligature sets and other OpenType features is actually pretty broad already and can be used in most scenarios. That's a viable way of providing the feature not only on the web but in a lot of editors that are browser based. Some of them are buggy at the moment but I don't think it will be long before accessing alternate ligatures is viable in a lot of editors.

Terminal based editors (where I live) are another matter. It might take a second version of the font to make that viable at all.

lozandier commented 9 years ago

I also agree with the original poster of this issue for ligatures to be supported.

Regarding the thread about the usefulness of ligatures @chrissimpkins @alerque has started, ligatures are a no brainer to have on by default as ligature by definition enables monospace typeface to better communicate the intent of two or more characters than they could by themselves. In the context of code, enable better understanding of the intent of the code

Being a monospace font, editors that can't support them should have no problem having Hack being used like any monospace font.

In other words, they gracefully degrade. It shouldn't be "off" (efforts that deliberately not allow the ligatures to be used out-of-the-box like any other Openttype typeface) as it would break the principle of least surprise as far as the OS. Editor's often by convention make it a opt-in feature since the developers of editor's may find it worthwhile to accommodate users of a non-monospace typeface that may

It's more of a matter of a serious effort be made, more than anything else. If ligatures of a monospace typeface makes the intent of a set of characters in the fixed-width space they occupy more confusing for development (it's a monospace typeface after all), then that typeface has failed the users of that typeface.

This feature is extremely important for languages that encourage or enable functional or async programming paradigms as needed for applications often such as Haskell, Swift, Go (esp. CSP), JavaScript, & etc.

In 2015, it should increasingly be the norm.

alerque commented 9 years ago

I'm sorry @lozandier but I don't buy that line of reasoning. Here's why.

First, OpenType ligatures being off by default is quite normal. Lots of fonts have a few of the more subtle possible ligatures enabled and many more of the possibly disruptive or unexpected ones off by default and behind discretionary flags. The same goes for stylistic alternative glyphs. Usually the more generic glyph is the default and the fancy-pants ones are behind a discretionary flag. This is normal. Nothing about doing this violates least surprise principles.

Second, source code ligatures do not always easily decompose into their component parts. Your typical ligature for fi is barely distinguishable to the untrained eye and it would hardly cross anybody's mind to type anything but an f and an i to get it. On the other hand nothing about seeing what looks like ≠ in my document will make me thing to type ! then = to get the glyph unless I am familiar with the underling programming language's syntax and the relation of that syntax to the meaning and to the ligature glyph. In this sense enabling such ligatures by default for a general purpose font would violate the principle of least surprise.

Third, for a general purpose font that is not aware of it's context, such ligatures would necessarily b wrong in some contexts. You cannot go wrong with the component glyphs but you can be wrong about when a ligature should be rendered. Maybe a code comment was giving an example from another programming language. Maybe something the character sequence is in the terminal for some reason other than being part of source code. Changing this behavior by default across the board would be frustrating for people that didn't know what was happening or how to fix it because it's not normal behavior. On the other hand folks that knew the language they were coding in and that they wanted to see fancy ligatures should have no problem adding the option flag to their font config.

Lastly not all programming languages will be compatible with the some set of ligatures. Whichever ones you enable by default would invariably end up being wrong for some language. On the other hand if you create ligatures and tag them in the appropriate font features table it's possible to create sets that would include all the appropriate ones on a per programming language basis. This would enable power users familiar with a language to enable ligatures for it in their editor for those files without screwing with their minds for languages whose syntax is new to them.

I look forward to having ligatures as an option, but think trying to make them on by default would be a huge mistake for a general purpose font even if it make perfect sense for a language specific or specialty font whose primary purpose was to provide this feature for a known scenario,

lozandier commented 9 years ago

I meant attempting to have workaround that would disable them in contexts they normally would be enabled by default.

For editors, they would be turned off by default; it would break the principle of least astonishment if they were all of a sudden on by default.

On Mon, Sep 7, 2015 at 4:08 AM, Caleb Maclennan notifications@github.com wrote:

I'm sorry @lozandier https://github.com/lozandier but I don't buy that line of reasoning. Here's why.

First, OpenType ligatures being off by default is quite normal. Lots of fonts have a few of the more subtle possible ligatures enabled and many more of the possibly disruptive or unexpected ones off by default and behind discretionary flags. The same goes for stylistic alternative glyphs. Usually the more generic glyph is the default and the fancy-pants ones are behind a discretionary flag. This is normal. Nothing about doing this violates least surprise principles.

Second, source code ligatures do not always easily decompose into their component parts. Your typical ligature for fi is barely distinguishable to the untrained eye and it would hardly cross anybody's mind to type anything but an f and an i to get it. On the other hand nothing about seeing what looks like ≠ in my document will make me thing to type ! then = to get the glyph unless I am familiar with the underling programming language's syntax and the relation of that syntax to the meaning and to the ligature glyph. In this sense enabling such ligatures by default for a general purpose font would violate the principle of least surprise.

Third, for a general purpose font that is not aware of it's context, such ligatures would necessarily b wrong in some contexts. You cannot go wrong with the component glyphs but you can be wrong about when a ligature should be rendered. Maybe a code comment was giving an example from another programming language. Maybe something the character sequence is in the terminal for some reason other than being part of source code. Changing this behavior by default across the board would be frustrating for people that didn't know what was happening or how to fix it because it's not normal behavior. On the other hand folks that knew the language they were coding in and that they wanted to see fancy ligatures should have no problem adding the option flag to their font config.

Lastly not all programming languages will be compatible with the some set of ligatures. Whichever ones you enable by default would invariably end up being wrong for some language. On the other hand if you create ligatures and tag them in the appropriate font features table it's possible to create sets that would include all the appropriate ones on a per programming language basis. This would enable power users familiar with a language to enable ligatures for it in their editor for those files without screwing with their minds for languages whose syntax is new to them.

I look forward to having ligatures as an option, but think trying to make them on by default would be a huge mistake for a general purpose font even if it make perfect sense for a language specific or specialty font whose primary purpose was to provide this feature for a known scenario,

— Reply to this email directly or view it on GitHub https://github.com/chrissimpkins/Hack/issues/35#issuecomment-138225930.

Kevin Lozandier lozandier@gmail.com lozandier@gmail.com

i-am-the-slime commented 9 years ago

How about having two versions of the font? Hack and Hæck. So people can choose themselves whether they want Ligatures or not.

lozandier commented 9 years ago

That doesn't seem to be efficient al all, if the ligatures tables can be in the font file as any normal font file & then they're disabled (which they often are ). Why have to files for something that can be represented in one file?

Even editors that support ligatures wisely make you opt-in of having them enabled; it's also a usability issue when they both are installed in systems that have a wide variety of fonts to the extent they need a font manager app to selectively disable & enable fonts: It's seems excessive to account for two variants of the same typeface when the only difference is ligatures.

On Sun, Sep 13, 2015 at 6:26 AM, Mark Eibes notifications@github.com wrote:

How about having two versions of the font? Hack and Hæck. So people can choose themselves whether they want Ligatures or not.

— Reply to this email directly or view it on GitHub https://github.com/chrissimpkins/Hack/issues/35#issuecomment-139858283.

Kevin Lozandier lozandier@gmail.com lozandier@gmail.com

chrissimpkins commented 9 years ago

Thanks to all for the feedback here. I really like the idea of ligatures with the caveats that I expressed in the thread above. I wanted to provide an update on this issue. I reached out to Tal Lemming (@typesupply) and Ellen Lupton to see if they would be willing to lend their expertise on this and a number of other type design related issues with the project. I think that the concept is great and the question is how we execute this without interfering with the information contained in the source.

For the proponents of ligatures, might I ask that you do a bit of research into the breadth of support that there is for these in widely used source code text editors (including for discretionary ligatures) and the level of difficulty that there may, or may not, be with settings to activate or inactivate the ligatures? I know that Andreas Larsen did a bit of work on this for his Monoid project and we can begin by validating and extending the information that he provides in the README on his Github repo. With this information, we can decide whether we need to clamor for more extensive support by the developers of editors and/or improvements in settings / ease of use of settings to take advantage of these OpenType features. This will allow us to have an informed discussion about ligatures in a working font. We can decide from there whether this is more appropriate as a separate build or within the main release.

While use as a working font in source code editors is the most common application of the typeface at this point, it is not the only one. We need to take this into consideration with developments that (1) may not be attractive to all groups of users and (2) could limit, or eliminate, its use for other purposes because we force users to either use new features like ligatures or introduce an inconvenience that they must design around to avoid use in cases where this is optional (e.g. the CSS web font examples provided above). This does not exclude the possibility that we could be creative in our design and create something that addresses these concerns. I am very open to more feedback and will continue to keep an eye on the discussion here.

alphapapa commented 9 years ago

My two cents, if I may: Hasklig-style ligatures are pretty, but they are by no means intuitive in this context. If a user types two characters on the keyboard, and they suddenly turn into a single character that may or may not actually resemble the two characters put together, it appears as a bug in the font or editor.

If a user is learning a new language, and he's reading the docs, and he sees that inequality is written as !=, but then he looks at some code in his editor and sees a , he is going to be confused. Unless he practically has all the ligatures in the specific font memorized, he is likely to be confused.

What if someone wants to search for a symbol? If one is searching for !=, but seeing , he must remember to type in not what he sees, but the hidden symbols behind what he actually sees.

And in this "Unicode age," where nearly every symbol imaginable has an actual code point and character in some system font, how does one know that he's seeing a ligature and not the actual Unicode character?

What if someone takes a screenshot and shows it to people who know nothing of these magic ligatures? What if someone sits down at another person's computer and sees these ligatures?

They can look very nice, but I'm afraid they are just not a good idea for general use. If the build infrastructure can support a custom build with them, then I'm all for giving people options. And if editors begin to support ligatures, then I'm all for having them in the font as built-in alternatives. But they should definitely not ever be a default feature. To do so would condemn the font to be used by virtually no-one.

They are pretty, though. :)

chrissimpkins commented 9 years ago

from @stefan-kern:

Hasklig: https://github.com/i-tu/Hasklig Monoid: https://github.com/larsenwork/monoid FiraCode: https://github.com/tonsky/FiraCode

all of those fonts come with ligatures for the most common programming operators like:

<* <> <+> <$> ** <|> !! || === ==> <<< >>> <> +++ <- -> => >> << >>= =<< .. ... :: -< >- -<< >>- ++ /= ==

since hack aims to be a code typeface it might be a good idea to include these common ligatures aswell.

chrissimpkins commented 9 years ago

Atom editor now supports ligatures:

http://blog.atom.io/2015/10/29/atom-1-1-is-out.html

lozandier commented 9 years ago

Atom already did via author style sheet; I've literally used ligatures in Atom for years.

On Saturday, October 31, 2015, Chris Simpkins notifications@github.com wrote:

Atom editor now supports ligatures:

http://blog.atom.io/2015/10/29/atom-1-1-is-out.html

— Reply to this email directly or view it on GitHub https://github.com/chrissimpkins/Hack/issues/35#issuecomment-152765830.

Kevin Lozandier lozandier@gmail.com lozandier@gmail.com

chrissimpkins commented 9 years ago

@lozandier I see. They seemed to push this as news. I don't use Atom.

lozandier commented 9 years ago

I don't use it often either; I primarily use Vim or Webstorm

On Saturday, October 31, 2015, Chris Simpkins notifications@github.com wrote:

@lozandier https://github.com/lozandier I see. They seemed to push this as news. I don't use Atom.

— Reply to this email directly or view it on GitHub https://github.com/chrissimpkins/Hack/issues/35#issuecomment-152773376.

Kevin Lozandier lozandier@gmail.com lozandier@gmail.com

ioquatix commented 9 years ago

+1

treybrisbane commented 9 years ago

+1

In response to your request for research, Chris, the FiraCode page on GitHub has a fairly extensive list of editors with and without support for ligatures: https://github.com/tonsky/FiraCode#user-content-editor-support

chrissimpkins commented 9 years ago

@tbrisbane thank you

chrissimpkins commented 9 years ago

We’re tossing around the idea of starting a branch of Hack that includes ligatures and will serve as “working fonts” for development in text editors. This will be developed in parallel with the main Hack branch, be released under a new font name, and address the mounting interest that you’ve expressed here.

For those who are interested in this, will you please chime in again with:

As you work through the above, I’d ask you to also begin to think about the design of the ligatures that you suggest. As this materializes, we will plan to create issue reports for the ligatures where the design can be discussed in much more detail. It will be impossible to meet everyone’s demands / needs, but ideas are extremely helpful and will drive the design as the set matures.

Lastly, it would be helpful to have at least one individual with development experience in each language that we define as our supported target languages (see above) who would be willing to commit to testing these during the early, active development phase.

Let’s see what we can pull together. Please continue the discussion here for now.

i-am-the-slime commented 9 years ago

Hi, So Hæck it is :). I am particularly interested in Scala ligatures and can test drive them. The tool I use is IntelliJ idea which has some beta support for ligatures (https://youtrack.jetbrains.com/issue/IDEA-127539).

The single most important character combination in Scala is => which can even be written as but that character looks odd in monospaced fonts. Same goes for -> and <-, which are the next most language specific combinations. In Scala, many popular libraries have also popularised other types of arrows and other combinations deserving of ligatures: ~>, ==>, ~~>, :=.

There are also some other more general purpose characters which occur in a great many languages: ==, !=, <=, >=, ===, ++, &&, ||. I would personally love for the ! character followed by any letter in abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ to translate to a not character: ¬. I have not seen any other font do that. It would leave exclamation marks used in sentences unaffected, since they are followed by a space. Another cool thing would be for nested parenthesis to render following ones a bit smaller, but that wouldn't work for an arbitrary number of them and at low font sizes.

That's all I can think of for now. It got a bit stream of consciousnessy towards the end. Sorry for that.

chrissimpkins commented 9 years ago

Hæck it is

+1 haha! I love this. Thanks for all of this information. Look forward to this discussion.

wottpal commented 9 years ago

For me would be important implementing the ligatures the "monoid-way" because like in the Atom 1.1 release notes states this is the only one where it is possible for atom to set the cursor between the two ligature-symbols: http://blog.atom.io/2015/10/29/atom-1-1-is-out.html

Note that there is a limitation with FiraCode and Hasklig that does not allow placing the cursor between combined ligature characters like ->. This is a limitation in the Chrome DOM measurement API. monoid does not have this limitation due to the way it implements ligatures."

burodepeper commented 9 years ago

I am still not pro-ligatures, but otherwise +1 for the "monoid way", because of not breaking the fixed-width paradigm.

From a purely visual perspective, I'm also not yet convinced. The examples of ligatures I've seen so far break up the vertical rhythm of the columns.

GauthierPLM commented 9 years ago

I'm looking for classic ligatures first, who are present in a majority of languages : ==, ===, !=, !==, >=, <=, ::, ->, ++, --, &&, ||, .., ..., <<, >>, +=, -=, *=, /=, %=, **, =~, <>, <=>, //, /*, */, <!--, -->, </, />,

A big part of this ligatures could be tested with common languages (CPP, Perl and HTML should cover all ligatures in my list). As @i-am-the-slime, I use IntelliJ IDEA to code, and KDE soft sometime (kate, ...).

i-am-the-slime commented 9 years ago

Alright some more for scalaz. Wenn schon, denn schon (come on, Kendos-Kenlen just said: "majorité")! <*>, |@|, |+|, <=<, =<=, |->, >>>, (and the other ways around). Are you using fontforge to make this font? I could try and add some ugly ones that could be improved upon to get the idea across.

chrissimpkins commented 9 years ago

goal is to make the development independent of the font editors through UFO source files. It's not there quite yet but that is next in the queue. we are using Glyphs for most of the design and FontLab Studio for table definitions and builds at the moment.

chrissimpkins commented 9 years ago

and you are more than welcome to contribute. we will create a new repo and work off of UFO files for this branch. Font Forge supports ufo source

ghost commented 8 years ago

does this new repository exist already (didn't find any)? if so, can you please share a link

chrissimpkins commented 8 years ago

@stefan-kern https://github.com/source-foundry/Hack-dev

chriskrycho commented 8 years ago

@chrissimpkins, here chiming in to say I'd love it as well. Just checking in: what's the status on any update—I see the dev repo hasn't been updated in a while? (No rush, just curious. :smile:)

chrissimpkins commented 8 years ago

@chriskrycho Time is short and the list is long! We were using the dev repository to collaborate on a fully scripted build approach as v3.x but @jublo has been tied up with other projects and this has stalled for the moment. That is why you haven't seen commits there. I am working in the development branch of this repository to develop the main sets and work remains very active. We just released a new set of fonts last week and work is underway on the next release (with an available set of testing builds for the first set of changes!). I would like to have solid main sets before I start diverting my time to variants (including requests for sets with different line spacing, condensed sets, and this request for ligatures). All of these requests for new variant builds remain on the list and would definitely move forward more rapidly if there is anyone out there with interest would be willing to help with the work. Consider this an open invitation and stay tuned!

chriskrycho commented 8 years ago

@chrissimpkins Thanks for the quick response! I hear you on all fronts, and am delighted to hear that work continues apace. If I knew what I was doing with typeface design tools, I'd pitch in myself.

mynetx commented 8 years ago

@chriskrycho Thanks for your interest! The scripted build approach that Chris mentioned hasn’t died—it’s just on ice for now. I may be able to resume contributions on this over the next time and will make sure to keep you updated! :)

Grandt commented 8 years ago

My two Knuts worth. Looking at FiraCode I have to say that I really dislike some of their ligatures. Especially the ones for => and <=, which they translate to ≥ and ≤, only their "equal" line is parallel to the bottom diagonal of the arrow. IMHO that breaks one of the fundamental needs of any font, especially one used for coding, namely that intent should be easily determined at a glance. the FiraCode versions look far too much like the regular > and < characters. Either the equal line must be horizontal, or better yet, at least that ligature ought to be omitted. Other FiraCode ligatures do a very good job of making the code less readable.

i-am-the-slime commented 8 years ago

Well you just made a great point why these ligatures do make sense: => does not get translated to . It is translated to , which is what it means. Very easy to get this wrong without ligatures, almost no chance with ligatures.

Grandt commented 8 years ago

Great point regarding catching the typo in my post :) I'm not against ligatures, I just wanted to point out that some are better than others, and FiraCode's version of less-than-or-equal-to or greater-than-or-equal-to are good examples of bad ligatures IMHO.

That said, most IDE's would probably mark that typo as an error. => usually makes no sense in the parts of the code where it should have been >= and vice versa.

treybrisbane commented 8 years ago

IntelliJ IDEA has just added full support for ligatures!

Has there been any further work on this?

ignatov commented 8 years ago

Hi all, I've just spent several hours tonight and create ligatures for == and != for Hack Regular. I'm going to add more of them, but the issue is that I'm using Glyphs not FontLab. @chrissimpkins Could you please give me a piece of advice how to contribute to the main repo with FontLab VI.

screenshot 2016-07-20 14 31 07

Please see https://www.dropbox.com/s/owzd20463aqc40a/Hack-Normal.ttf?dl=0

Defman21 commented 8 years ago

Looks good! What characters did you add? != and ==?

ignatov commented 8 years ago

@Defman21 Yes, != and ==.

chrissimpkins commented 8 years ago

@ignatov Thanks for your work on this! My opinion about ligatures is that they belong in a separate developer 'working font' based on Hack (like Fira Code is to Fira Mono). Happy to commit the separate fonts here if you would like. This will require a new set of source. Likely the better option to provide you and anyone who would like to collaborate on this with complete control on its progress is to fork and create a new repository for it. We will point there from these threads and I am happy to include information about it in the documentation. Based upon the interest in it over the last several months, I think that you will gain traction from the ligature crowd who will be more than willing to suggest visually appealing ligatures for code editors. This works well for those who know that the ligatures are present and expect these character changes in the body of the source text.

Anyone else out there interested in this work feel free to chime in about the best approach for progress to happen with this ligature derivative of Hack.

And this should go without saying, but please take advantage of your libre rights and do feel free to make derivatives of Hack to create new things. This is a good thing and all of us who have committed to the project would love to see it used as an upstream for other projects (as we have done with DejaVu and Bitstream Vera).

treybrisbane commented 8 years ago

@ignatov Good stuff! :D

Any plans on forking the Hack repo as Chris suggests above? I'm no font designer myself, but I suspect Chris is right in saying that a dedicated ligature fork of Hack will definitely encourage collaboration on this feature.

ignatov commented 8 years ago

@chrissimpkins @tbrisbane Thanks for the reply. So I'm going to create a separate repo for the font with ligatures.

chrissimpkins commented 8 years ago

:+1: let me know if/how I can help. I can get you started with our ttfautohint hinting scripts if you need. Definitely recommend that you use them. They are tuned to the Hack set.

caizixian commented 8 years ago

+1 for optional ligatures

chrissimpkins commented 8 years ago

@ignatov did you create this fork?

ignatov commented 8 years ago

@chrissimpkins not yet.

chrissimpkins commented 8 years ago

@ignatov no worries. was just going to give users here the link if so