3 ms·
Shaping ligatures in monospace fonts
- california-og 2y agoFonts are kind of dumb. There's usually nothing actually weird going on. Ligatures are simple character substitutions. What the LIGSPACE is, most likely, is a spacing character added by the designer to align the characters in the ligature correctly. So, the LIGSPACE is just a character like any other and is nothing special. For example, when you hit a space bar, you are inserting a character which doesn't render anything because the designer didn't draw anything there. There's no extra logic.
- eqvinox 2y agoI would recommend learning the difference between a character and a glyph; it's the first thing to learn in understanding fonts and font rendering.
- hbosch 2y ago>Since we are working with a monospace font, every glyph must have the same advance Just pointing out that this is merely an expectation and not a rule. You can happily design a "monospace" font in any font publishing software that blatantly disrespects a single width. In fact, you can just manually make any letterform 2x width, and that is exactly what most monospace ligatures do! (except the bad ones, which combine e.g. "fi" ligature a single width letter) The ligature letters are just... 2x width. Believe it or not this is totally legal! https://www.hanselman.com/blog/monospaced-programming-fonts-with-ligatures https://www.hanselman.com/blog/monospaced-programming-fonts-...
- DHowett 2y ago> > advance > you can just manually make any letterform 2x width, Yes. Any glyph may be wider than its advance. The advance, however, must remain the same across all glyphs. If it does not, the font is not monospaced. The passage you’ve quoted refers not to the width, but to the advance.
- Etheryte 2y agoI think the ligature from MonoLisa is a good example of how not to do ligatures. I can't tell whether it stands for "#={" or "#{". Ligatures can be nice, to each their own, but only if they don't introduce ambiguity.
- propter_hoc 2y agoIt also makes no sense and looks terrible to connect those two glyphs with a ligature. Unlike "fi" or "ij", there's no reason (kerning or spelling) to want to smush # into {.
- weinzierl 2y agoI don't doubt that but I cannot really pinpoint what the reason is to want "fi" and "ij" in a monospace font? Do these narrow letter ligatures then take up only a single character cell?
- stevesimmons 2y agoIf you're Dutch, "ij" is a technically a single letter, and may sometimes be written as "y". (Traditionally, Dutch words are sorted alphabetically with "ij" treated as if it were "y". On my first visit to Amsterdam, pre-Google Maps, I had the bizarre experience of standing in one of the main streets, Vijzelstraat, but being unable to find it on my map. Its index of streets has nothing starting "Vij...". I sheepishly had to ask someone wtf was going on. He pointed me lower down to the end of the "V"s where all the "Vij..." street names were hiding!)
- WorldMaker 2y ago#{ in a few languages is a bit of a high-level operator like "start a record/object/hash table". The # is visually a bit like a handle on a coffee cup (which you are about to fill). The octothorpe (#) is also sometimes called a "hash", making it also a bit of a visual pun if it is indeed the start of a hash-table. (Think JSON object syntax in a language where you want to make sure you can't just accidentally write objects anywhere or confuse different uses of { such as starting a code block, so you put a handle on them.) "Smushing" it together makes it even more visually distinct as a "single" operator, further adds to the visual metaphor of the "coffee cup handle", maybe obscures the "hash" visual pun a little bit, but maybe not enough to care.
- p4bl0 2y ago> The text is almost all English with glyphs from the Basic Latin Unicode block. Well, the code text probably, in most programming languages. But code also contains comments, and comments are very often written in other languages than English in personal project and/or during development phases before clean up for merging, and sometimes even after that.
- Shugyousha 2y agoIn general, I think having ligatures in a monospace fonts is a bad idea. The reason is that in a monospaced font all the glyphs are supposed to the same advance value. This forces the ligatures to always take up the same space as two (or however many glyphs) are involved, which may stretch the ligature glyph in a non-intended way (if it is even possible to rasterise it that way). Monospace fonts are also often used for programming (because they make sure that the columns line up consistently, regardless of the font being used). I personally don't see the point in showing ligature glyphs that do not correspond to the actual Unicode code points encoded to bytes in the source code. Just my 2 cents.
- InsideOutSanta 2y agoRationally, what you say makes sense, of course. But I love ligatures for programming. First of all, I think they just look nice. But second, I also feel that for me, they make code a bit more readable. Without ligatures, multiple characters are often used to create one symbol; with ligatures, one symbol is always rendered as one single visual character. So if I read code, it just feels a bit easier for my brain to parse ≥, rather than >=.
- Zanfa 2y ago> So if I read code, it just feels a bit easier for my brain to parse ≥, rather than >=. Clearly there's personal preferences involved, so there's no objectively better or worse, but it still blows my mind, because reading ligature symbols like ≥ and ≠ always makes my brain skip a beat, so I need to reread a few times to "get it".
- WorldMaker 2y agoSome of that subjective influence with ≥ and ≠ especially is how much time you've spent in math courses or reading math papers. For some of us those have always been the "real" operators and >= and != the fallback replacements that look "close enough" in easy to type ASCII. We were sort of doing the opposite all along, translating the ASCII breakdowns into the math notation in our heads, and ligatures can feel like a bit of a relief because now you see the "real thing".
- Stratoscope 2y agoWhy should code have to be in a monospace font? I've read and written all my code and that of others in proportional fonts for at least 15 years. Of course there are coding styles that look better in a monospace font, e.g. if you use column alignment instead of simple indentation. But even those are nearly as readable in a proportional font. So things don't line up perfectly? Big deal. As a specific example, any Python code formatted with Black will be equally readable in a proportional font or a monospace font. This is because Black forgoes column alignment tricks and uses simple indentation for everything.
- Suppafly 2y agois the font just named 'black'?
- p4bl0 2y agoThe "Black" thing discussed here is not a font, it's a code formatter for Python: https://black.readthedocs.io/ https://black.readthedocs.io/
- WorldMaker 2y agoBlack is a common "opinionated" code formatter for Python, like Prettier is for JS/TS/Markdown/more or `go fmt` for go. https://black.readthedocs.io/en/stable/index.html https://black.readthedocs.io/en/stable/index.html
- upofadown 2y ago>Why should code have to be in a monospace font? Because it usually is. Most people have learned it that way. What would be the point in having to learn both ways? Having the characters on a grid makes it less likely that two characters will be interpreted as a single character. Absolute legibility is better with monospaced fonts. Programming involves a lot of characters adjacent to one another that are normally not in prose. You could turn the question around: why anyone would ever use proportional fonts for anything other than prose? The only real advantage that a proportional font has is that you can squeeze more text into a particular space and as a result you can read faster. The increase in reading speed comes from the sort of context that you normally don't have for programming. The increase in the amount of text is not reliable (it depends on the number of thin characters) and as a result is not helpful for programming.