larsenwork / monoid

Customisable coding font with alternates, ligatures and contextual positioning. Crazy crisp at 12px/9pt. http://larsenwork.com/monoid/
7.85k stars 170 forks source link

Add ligatures #25

Open larsenwork opened 9 years ago

larsenwork commented 9 years ago

Like e.g. https://github.com/tonsky/FiraCode

I'm still trying to figure out how best to solve it technically though

larsenwork commented 9 years ago

So I think I've figured out how to do some of it. I'm trying to keep this a strictly monospaced font so hack job like combining two characters in to one wider character isn't kosher. Instead I'm thinking about using contextual substitution like this

feature calt {
  sub less hyphen' by ligaarrowleft;
} calt;
feature calt {
  sub less' ligaarrowleft by space;
} calt;

so that all glyphs still have the same width.

screen shot 2015-06-06 at 07 53 14

larsenwork commented 9 years ago

monoidvsroboto

I've added these so far but having some issues with "calt" and Atom (editor I'm primarily using)

glebd commented 9 years ago

I wonder if this is going to work in Visual Studio on Windows. Pragmata Pro and Hasklig ligatures seem to work there. In case they work, it would be great to have =>, // and /// for C# in addition to the ones above. Also, for F# (which is cross-platform) |>, <|, <||, <||| (* *), (| |), ::, :>, :=, <<<, >>>, [| |], [< >] etc. would be great. The full list: https://msdn.microsoft.com/en-us/library/dd233228.aspx

larsenwork commented 9 years ago

@glebd can you check the latest version and see if it works on windows with these ligatures https://github.com/larsenwork/monoid/issues/25#issuecomment-111757957

larsenwork commented 9 years ago

@glebd should => be an arrow like this: ⇒ or what is it used for? I have added // and /// (not pushed yet)

glebd commented 9 years ago

Yes, I think so: => turns into ⇒ across 2 character widths. Thanks!

larsenwork commented 9 years ago

@glebd cheers, did you get to test it on Windows?

glebd commented 9 years ago

Not yet, will do next week

larsenwork commented 9 years ago

:+1:

larsenwork commented 9 years ago

screen shot 2015-07-19 at 22 26 04

larsenwork commented 9 years ago

Compared to screen shot 2015-07-19 at 22 33 00

glebd commented 9 years ago

Niiice

larsenwork commented 8 years ago

@glebd I don't know haskell but is this something I should fix (comment about >→) https://news.ycombinator.com/item?id=9718099

And are there other similar issues?

mo-seph commented 8 years ago

These are lovely!

I'm writing in a language where => and <= are both arrows, and at the moment it's a bit confusing as:

Unfortunately, some of this is language and context dependent. For me there are times when <= is an arrow, and times when it is less that or equal to.

Could the download page (which is great, btw) allow a choice of ligatures as well as just on and off?

larsenwork commented 8 years ago

@mo-seph cheers, => should be a ligature. What editor + OS are you using? screen shot 2015-07-24 at 10 40 30

<= vs ≤ could be a choice, the easiest (and best thing) would be to add it as an stylistic alternate, but that only works if your editor allows you to add your own stylesheet.

It could also be a downloadable choice but problem is we're currently generating all possible versions (current 3200) so adding it as downloadable choice would require it replacing one of the existing options.

larsenwork commented 8 years ago

What language uses <= as arrow?

mo-seph commented 8 years ago

An obscure one ;) It's called LCC, and represents messages sent to ( => ) and from ( <= ) agents (https://bitbucket.org/mo_seph/scalsc/wiki/Representing%20Interactions)

Here's a screenshot, using Eclipse on OSX 10.10

screen shot 2015-07-24 at 09 50 19

The <= on line 7 has been changed to leq as expected, the => on line 8 is un-liga'd, and the <- on line 9 is great ;)

(BTW, these arrows are clearly an edge case, and I suspect your approach works for 99% of the time ;) )

larsenwork commented 8 years ago

@mo-seph => should be a ligature. What editor + OS are you using?

mo-seph commented 8 years ago

Eclipse, OSX 10.10.4

flaviotruzzi commented 8 years ago

Ligatures are not working here :( (IntelliJ OSX 10.10.4)

chase commented 8 years ago

@larsenwork It seems like Java doesn't support ligatures, at least not on OS X. Eclipse and IntelliJ are both Java-based.

EDIT: Turns out that IntelliJ's rendering engine doesn't support ligatures, Eclipse does in fact.

mikebronner commented 8 years ago

Crud, I guess that holds true for PHPStorm 9 as well (built on Java).

chase commented 8 years ago

@mikebronner Since it is a derivative of IntelliJ, I'd say that's safe to assume.

rkurbatov commented 8 years ago

@mikebronner @chase Eclipse is supporting ligatures, just checked. IntelliJ doesn't - they've changed rendering engine. They are working at this. SublimeText too.

chase commented 8 years ago

@rkurbatov Thanks for looking into it!

larsenwork commented 8 years ago

Please add your findings to the readme #67

larsenwork commented 8 years ago

@glebd About the // ligature: would it make sense to only activate it if it's preceded/followed by a "space" ?

I want to turn it off for at least http:// which currently look a bit odd with the ligature

glebd commented 8 years ago

Not really, as C-like languages use // for comments which may start at the beginning of the line.

larsenwork commented 8 years ago

@glebd space after?

glebd commented 8 years ago

Hmm, some people don't leave space after //comments.

larsenwork commented 8 years ago

Hmm...they should, looks messy:) Well I can easily "filter out" http:// so I'll just take that approach instead.

glebd commented 8 years ago

Cool.

plgruener commented 8 years ago

suggested/requested ligatures (mostly from Java and Groovy, see full list here ) ++ (maybe same as with == and --) operators += -= = /= %= * *= =~ ==~ <=> "Spaceship-operator", currently this is broken into <= and > for comments (without the spaces) / * , / * * , / (similar to //) also cool would be ?: ?. !! *. ..<

larsenwork commented 8 years ago

One could do the same as == and -- for ++ but not sure. Plus signs have a vertical line making it easy to tell them apart so not sure the ligature is necessary screen shot 2015-07-27 at 12 26 12 Spaceship: We could go crazy and do something like this screen shot 2015-07-27 at 12 25 33 but I'm more inclined to do something like this screen shot 2015-07-27 at 12 28 34 As for the operators we could do narrower +-= signs but not sure it's needed screen shot 2015-07-27 at 12 32 23

plgruener commented 8 years ago

Spaceship: that indeed looks crazy somehow :D But I'd also go with the (sane) second version. ++ and \ : right, probably not needed. But it looked slightly strange because all others (==, --) have these little gaps.

Same goes for *= %= etc. Not really necessary, but I think a little gap (narrower = signs) would make it prettier (just my personal opinion, you're the font expert ;)

larsenwork commented 8 years ago

Been looking at it and I might just change the default =+- to the narrower versions

larsenwork commented 8 years ago

So it'd be like so: screen shot 2015-07-27 at 13 49 54

plgruener commented 8 years ago

Well, that'd save you some work with the ligatures. However, I don't quite like that asymmetrical plus sign, looks a bit odd to me. I don't know about your build process, but maybe you can offer an alternate version with narrow +-= signs, so some more people can test it (at different sizes).

larsenwork commented 8 years ago

Yeah...I actually like the narrower equalsign as default and then keeping the + and - unchanged but have the ligature for --

screen shot 2015-07-27 at 14 52 53 screen shot 2015-07-27 at 14 54 27 screen shot 2015-07-27 at 14 55 31

plgruener commented 8 years ago

Yes, sounds like a good solution. Do the unligatured versions of >= => etc. still look good with the narrow equal-sign?

larsenwork commented 8 years ago

@plgruener I think so - they look like the spaceship (3rd pic): https://github.com/larsenwork/monoid/issues/25#issuecomment-125159686

plgruener commented 8 years ago

Ah right. Looks great. (Except the -= has some unfamiliar proportions, but one should get accustomed to it pretty fast.)

larsenwork commented 8 years ago

The - in -= could be a hybrid between - and the - in -- screen shot 2015-07-27 at 16 30 26

larsenwork commented 8 years ago

Moving the first asterisk to the left and the second up and to the right to make more room for the comment screen shot 2015-07-28 at 01 24 55

larsenwork commented 8 years ago

@plgruener what are ?: ?. !! *. ..< used for? I need some context examples to see what ligatures (if any) will be fitting.

plgruener commented 8 years ago

Keep in mind one often formats comments like this:

/**
 *
 */

So I don't know about left/right shifting the asterisk…

larsenwork commented 8 years ago

It will look a bit weird but the gain in /Comment/ cases should be worth it.

plgruener commented 8 years ago

Well, actually comments like /* ... */ in one line are very discouraged (at least in Java & co.). But we could try it first.

larsenwork commented 8 years ago

In css they're everywhere :)

larsenwork commented 8 years ago

I actually think it works ok:

screen shot 2015-07-28 at 01 57 18