Alhadis / Menloco

Replaces the Monaco typeface's box-drawing characters with those from Menlo.
MIT License
25 stars 2 forks source link

Subpixel alignment of vertical lines in GUI apps #4

Closed silverwind closed 6 years ago

silverwind commented 6 years ago

When edge characters like and meet, I see this alignment issue:

screen shot 2018-02-25 at 11 46 31

The issue shows for me on macOS in Firefox, Chrome, Sublime Text and Atom, but interestingly not in iTerm. The original Menlo font does not show this issue:

screen shot 2018-02-25 at 11 57 34

Here's the example text:

 ┌─────────┐
 │  Lorem  │
 │  ipsum  │
 │dolor sit│
 │  amet,  │
 │consectet│
 └─────────┘
silverwind commented 6 years ago

Looks like the issue is even present on single characters. Here's the vertical beam in Chrome:

screen shot 2018-02-25 at 12 52 44

This is so weird. The character is vertical beam in the font file, at least according to FontForge:

screen shot 2018-02-25 at 12 54 14
Alhadis commented 6 years ago

That'll be because Menlo and Monaco use two different advance widths for their characters, which matters only when applications consider proportional sizing in font rendering. So in other words:

┌─────────┐ <- This row looks fine, because it only uses Menlo glyphs
│  Lorem  │ <- This row looks screwed, because it uses glyphs from
               both Menlo and Monaco

So as far as font metrics are concerned, you may as well have two completely different typefaces in use in the editor. If Menlo's advance widths are stored internally at, say, 1000, and Monaco's are 1004 or what-have-you, there's inevitably going to be a discrepancy when glyphs are mixed in a medium that isn't fixed-pitch.

This isn't easy to fix programmatically, I'm afraid. :disappointed:

Of course, if both fonts weren't commercial, I'd simply hack them together in an editor and upload the manually-corrected version. :grinning: But since they're proprietary, I had to write this entire repository just to share my work with the world.

Fuck closed-source.

Alhadis commented 6 years ago

Oh, and I was planning on making a similar repository to share my patched version of Menlo called Menlig (Menlo + ligatures), but I lost the source files with my MacBook. I was lucky enough to recover the OTF for it.

Here's how it looks in Konsole and Atom, or anything which supports OpenType ligatures:

screenshot_2018-02-25_22-26-11

Which I've uploaded here because I've well and truly had it with Apple.

/angry-diatribe-over

silverwind commented 6 years ago

Thanks. I'm personally not that much into ligatures, but I can recommend the Fira Code font if you like them.

As for this issue: You're right. Monaco uses a advance width of 1233 while Menlo has 1229, resulting in ever so slight misalignments. It might be possible to set the width of replaced glyphs to fix this issue, but I'm not sure if the font forge API (http://dmtr.org/ff.php) can do that.