Git Product home page Git Product logo

hasklig's Introduction

Hasklig – Ligatures for code

Programming languages are limited to relatively few characters. As a result, combined character operators surfaced quite early, such as the widely used arrow (->), comprised of a hyphen and greater sign. It looks like an arrow if you know the analogy and squint a bit.

Composite glyphs are problematic in languages such as Haskell which utilize these complicated operators (=> -< >>= etc.) extensively. The readability of such complex code improves with pretty printing. Academic articles featuring Haskell code often use lhs2tex to achieve an appealing rendering, but it is of no use when programming.

Some Haskellers have resorted to Unicode symbols (, etc.), which are valid in the ghc. However they are one-character-wide and therefore eye-strainingly small. Furthermore, when displayed as substitutes to the underlying multi-character representation, as vim2hs does, the characters go out of alignment.

Hasklig solves the problem the way typographers have always solved ill-fitting characters which co-occur often: ligatures. The underlying code stays the same — only the representation changes.

Not only can multi-character glyphs be rendered more vividly, other problematic things in monospaced fonts, such as spacing can be corrected.

Hasklig

Hasklig Sample

Source Code Pro

Source Code Pro Sample

Currently implemented symbols

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

Building the fonts from source

Requirements

To build the binary font files from source, you need to have installed the Adobe Font Development Kit for OpenType (AFDKO). The AFDKO tools are widely used for font development today, and are part of most font editor applications.

Some SVG glyphs are inserted into the fonts using Python FontTools.

Building font instances from masters

This repository only includes so-called master weights of the fonts (effectively extralight and black). The shapes of the weights in between these extremities are calculated by makeInstancesUFO supplied with .designspace files. For convenience, the shell script makeInstances is provided, which executes makeInstancesUFO, calculating all the italic and regular font weight shapes.

$ ./makeInstances.sh

Building one font

The key to building OTF or TTF fonts is makeotf, which is part of the AFDKO toolset. Information and usage instructions can be found by executing makeotf -h.

In this repository, all necessary files are in place for building the OTF and TTF fonts. For example, build a binary OTF font for the Regular style like this:

$ cd Roman/Regular/
$ makeotf -r

Building all fonts

For convenience, a shell script named build is provided in the root directory. It builds all OTFs and TTFs, and can be executed by typing:

$ ./build.sh

or this on Windows:

> build.cmd

Credits

Original idea, design and implementation of code ligatures by Ian Tuomi 2014-2015. This typeface extends Source Code Pro with ligatures.

hasklig's People

Contributors

0mp avatar alexpovel avatar arifer612 avatar brianleroux avatar curzy avatar dasmoose avatar dmitry-azaraev avatar dolmen avatar foxxmd avatar frankrolf avatar gerardvivancos avatar grawl avatar gregwebs avatar hyiltiz avatar i-tu avatar limenet avatar loichu avatar maecenas avatar miguelsousa avatar pauldhunt avatar ppicazo avatar robeerob avatar rojepp avatar rsperberg avatar ryanstewart avatar srid avatar statico avatar teotuominen avatar tjarratt avatar xiagu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hasklig's Issues

/= looks like "not equal"

To me the "/=" ligature looks like "not equal", and not like an assignment operator. I recommend to abandon this ligature or make it clearer. Since there are no ligatures for +=, *= and -=, I don't see any benefit in this ligature anyways, and it is confusing, because it looks similar to "==" but this is not an assignment operator.

Provide README file with a complete list of ligatures

It would be very nice to have the complete list of ligatures in plain text. This is useful, for example, for quick checking whether text editor properly supports all of them: you just copy & paste them into editor window and see if everything works as expected.

Another ligature request: =<

Hasklig works great for the ChucK language. Not only does it include a snazzy ligature for the all-important ChucK operator ( => ), but <<<, >>>, <<, >>, ==, ++, || and :: are also useful symbols in ChucK. I've been using it with success in ChucK's miniAudicle editor for Mac OS X.

If it's not too far out of scope, for symmetry's sake I'd like to request the addition of the unChucK operator: =<

Other ligature additions that would be useful in ChucK: != (does not equal) && (logical OR) -- (decrement) @=> (explicit assignment) +=> -=> *=> /=> %=> <<=> >>=> &=> |=> ^=> (various arithmetic and bitwise assignment operators). Perhaps I should be looking at creating a specialized ChucK coding typeface as a fork of Hasklig.

Cursor does not appear in middle of characters on Atom

I'm not sure if this is an Atom issue or a Hasklig one. There's an issue open at Atom here: atom/atom#11567 (comment)

Basically, with other fonts, like FiraCode, when you move the cursor through a ligature, it shows the cursor inside the ligature.

With Hasklig, it always shows the cursor on one side, which has led me to make many erroneous edits.

Is there something in the design of Hasklig vs FiraCode that would cause it? I much prefer the look of Hasklig, so it would be great if this issue were resolved.

Wrong letter height

The letter «Ч» is shorter than others:
cakskbrjwi

Reproduced in in Visual Studio Code.

State of Hasklig for emacs?

On twitter a few images of hasklig and emacs are floating around. And it says here that emacs support is in progress. What is the current state? And is there a way to help?

Google Web Fonts

This is pretty cool. How about getting hosted on Google Web Fonts?

Ligature Request: <=>

Ruby supports the "spaceship" operator, but Hasklig makes it look a bit funny. It'd be great to see something like the existing <+> ligature, but for <=>.

untitled_3_rtf

Request for extra ligature: `<=`

While it may not be used in Haskel, it would be nice to have a ligature for <=, akin to the ligature for =>.
This symbol is used in some other languages, notably as assignment operator in VHDL and Verilog.

xfce4-terminal support?

So I'd really like xfce4-terminal support since I use neovim inside of it and would really like hasklig. I've tried the pre-release version (apparently with support for more clients) and the stable one, and both don't work. I've also tried Konsole but I'm guessing my version is outdated since hasklig doesn't pop up in the font selection and fira mono doesn't work at all (no ligatures). So could xfce4-terminal support be added into the Hasklig font? Or would I have to open a feature request on xfce for ligatures?

More pronounced visual difference between == and ===

In some languages (PHP, JavaScript), there's a big difference between the two following comparison operators:

== : compare if same value
=== : compare if same value and same type

This makes it important to easily recognize which one you are using.

The current ligatures make the === operator a slightly longer version of the ==, and it is difficult to distinguish them at first glance.

In some other ligature fonts, the === is represented as three horizontal bars, instead of only two. This makes it immediately distinguishable from the standard two bars in ==.

The negated versions of these, != and !==, should get the same treatment.

Here's an example of how this looks in the Firacode font (https://github.com/tonsky/FiraCode):
screenshot 2016-07-13 15 33 24

Ligature request: =/=

Erlang has /= and =/= with different semantics, and if I type =/=, I get a visible space between = on the left and the ligature for /= on the right.

Also, am I mistaken, or is =:= already included?

List of stars get "unmonospaced"

I've just installed Hasklig on my Linux Mint and noticed a common "pattern" I had got broken-ish. Images say it better than words:

No-ligature font, normal code
screenshot_530

FiraCode, stars with ligatures
screenshot_531

Hasklig, ligatures make the line go further into the column limit
screenshot_532

I'm pretty sure I didn't add any stars to the last screenshot :)
Shots taken on PHPStorm, but the effect can be seen as well in Pluma/gEdit. Additionally, Storm goes crazy with the cursor in that line, as you can see through the image: it seems the characters are displayed in their correct column, even though the rendering is out of it.

Lens ligatures request

Hello! Would it be possible to add lens-related ligatures?
Here is the list of operators in Lenses: https://github.com/ekmett/lens/wiki/Operators

The most important would be ^., .~, %~ and ^?, but it would be so awesome to add support to greater number of them! I've seen that in some other ligature-aware fonts some of them are already supported, but nothing is so beautifull as Hasklig! :)

iTerm2

I know it is not supported for now, I just want to subscribe to any news in the regard of iTerm2.

How to modify Hasklig and apply to other fonts?

I'm interested in adding Hasklig-style ligatures to a proportional font like Source Sans Pro. However, looking at the code for Hasklig/source-sans-pro and instructions for building it, I can't get enough insight in how to do this. I think it would be of great value to the programming community if some information was provided on how Hasklig was developed from an open source font (what tools were used, how it was built, and so on) so that it could be modified and replicated in other contexts.

Strange looking(maybe anti-aliasing) in IntelliJ under Windows

OS: Windows 10
Editor: IntelliJ IDEA 2016.2 with JetBrains JRE
Font version: 1.0 beta with all weight installed
Source Code Pro:
image
Hasklig:
image
Feeling something maybe anti-aliasing goes wrong and make Hasklig looks weird.
I'm not a pro, don't know if it's an IDEA issue or Hasklig's.

Requesting even more ligatures

I would really love to see all of the following

! @ # $ % ^ & * | ? . , / \ " : ~

as ligatures with all of the following

<.> <. .>

so...

<!> <! !>
<@> <@ @>
<#> <# #>
<$> <$ $>
<%> <% %>
<^> <^ ^>
<&> <& &>
<*> <* *>
<|> <| |>
<?> <? ?>
<.> <. .>
</> </ />
<\> <\ \>
<"> <" ">
<:> <: :>
<~> <~ ~>

as well as the rest of the common binders:

>=> <=<
<**>
>>^ ^<<
<<^ ^>>

It would also be nice if \ without < or > would be displayed as λ. So...

\x -> x + 1
--becomes
λx -> x + 1

Lastly (I promise), it would be nice to see forall get displayed as giant .

URXVT support

I have been playing around with Hasklig in my URXVT configuration in .Xdefaults, but I haven't been able to display any of the ligatures. Has anyone found out how to do it (or whether it is even possible)?

Italic text looks strange in IDEA

Many characters (for example, /*, but others also) in italic look extremely strange in IntelliJ IDEA 2016.1.1:
image

The same looks fine if I add an additional star to the first line (I guess that changes the text to normal instead of italic):
image

Is it a Hasklig issue or should I report that to the IDEA developers?

Doesn't work with Chromium 41 / NW.js 0.12.x

While Hasklig ligatures work, if you toggle text-rendering: optimizeLegibility (needed for ligatures) on NW.js 0.12.x, which is using embedded Chromium 41.0.2272.76, the line-length of the "monospaced" font changes. text-rendering: geometricPrecision has the same error.

See: Crunch/Crunch-2#39

This is probably why support has been difficult for Chromium-based editors like Atom. The Hasklig font simply doesn't render as a monospace font.

add codepoint for ∘

Having a extra codepoint for the compositionoperator with a width of 3 chars, one could easily fontify these in emacs without fontifying name spaces

Support added in BBEdit 11

According to the release notes of BBEdit 11 font ligatures are now supported:

You can now turn on font ligatures with an expert preference. This allows enhanced text rendering behavior in certain fonts, such as the work-in-progress Hasklig font which uses ligatures to enhance the display of compound-character Haskell operators.

Ligatures may be enabled or disabled per font based on the font's display name. So, if you wanted to enable ligatures only for the Hasklig font, you would do it thusly:

defaults write com.barebones.bbedit EnableFontLigatures -bool NO
defaults write com.barebones.bbedit EnableFontLigatures_Hasklig -bool YES

The font's display name is the name as it appears in the "Fonts" panel or in the Font Book application; not the name of the font file on disk.

No full support by Atom?

I tried setting up this font in Atom, and after I disabled hardware acceleration and added body { text-rendering: optimizeLegibility; to my css configuration, it seemed to work, but the cursor shows up in the wrong place (and it gets worse the more ligatures you have in a line). The cursor shown here is actually at the end of the line:

screenshot from 2014-11-16 23 32 11

I just want to clarify if Atom has been able to use the font with full support before in a different config/version/system. I'm using the current version 0.146.0 on Ubuntu 14.04.

ligature not being applied when the characters word-wrap

Full disclosure: I only came across this yesterday in an article on Smashing Magazine's newsletter. It's a brilliant concept and it makes working in code much more visually appealing. I was a bit worried at first that the symbols might diminish the importance of the operator when the page is being scanned but my experience so far is that the opposite is true: they really jump out making the operation much clearer. Good work.

I'm using this font on a Mac in the Coda IDE and I've noticed that if the character pair is interrupted by a word-wrap that the ligature is not applied. Is this a problem with my IDE or can this be addressed within the ligature logic? Also if I resize the screen the ligature is applied correctly.

ligatures

Use contextual alternates instead of ligatures

This would enable cursor positioning "inside" ligatures in atom (see this and this). Would also help with #18.

I really love hasklig but the unintuitive insertion point behavior around the combination glyphs sends me back to plain Source Code Pro. 😢

Thanks for making Hasklig! ❤️

Weird ligature issues

The arrow ligature doesn't seem to work for me, and the triple equals only works when followed by another equals sign. (See attachment)

screen shot 2015-09-14 at 3 47 54 pm

How to build the font ?

I tried to execute ./buildAll.sh but it seems there is hard mentions of your personal files in it.

How can I build the fonts from the sources ?

I'm on Ubuntu.

Powerline symbol issues

One of the powerline symbols, glyph 969 (e0b3) is identical to glyph 697 (e0b1) but should be a mirrored version.

Request: ligatures for != and !==

Hello, I'd like to see ligatures for != and !==. When i first saw /= ligature it was pretty confusing to me, because it looks just like i would wanted to != look.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.