ryanoasis / nerd-fonts

Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more
https://NerdFonts.com
Other
54.25k stars 3.64k forks source link

Add variable-width monospace font sets that use fixed-width powerline glyphs #362

Closed Hebgbs closed 1 year ago

Hebgbs commented 5 years ago

In Nerd Fonts, there are two types of monospace fonts. This can be best understood with the UbuntuMono fonts which illustrate this: the UbuntuMono Nerd Font family and the UbuntuMono Nerd Font Mono family.

This presents a bit of an issue for users who want to play with the Powerline symbols which Ryan also makes. If one goes with the monospace Nerd Fonts with variable-width glyphs, that do not render correctly in a TTY, not only being cut in half there, but also certain Powerline symbols in a terminal emulator during an X session do not appear correctly in certain instances where right prompt is used, because of how variable width glyphs appear on that side of the terminal. Playing with certain glyphs for ASCII / ANSI art in the terminal also doesn't work because of the non-monospaced nature of the symbols. However this is resolved in part using Nerd Font Mono families of fonts.

I propose a new family: Alongside variable-width monospaced Nerd Font and Nerd Font Mono, Nerd Font Power Mono, which only forces fixed-width for Powerline and Powerline Extra symbols.

Additionally, for certain symbols which appear incorrect or not as intended in Nerd Font Mono families, the same glyphs which exist for current iterations of Nerd Fonts can exist in this family, but alongside it, split versions of glyphs starting from E0B8, up to E0CF, a half-width variant of E0D0 (which can be used twice for the same effect, or as two separate glyphs which act slightly different) and the right half of E0D1 which can optionally be used with a full-width block. This can be hosted as an entirely separate set of fonts, to be installed as supplementary to the existing Nerd Fonts set, or rolled into Nerd Fonts as proposed.

Nerd Font Mono sets could also use these extra symbols, though for convenience these half-width font symbols could just be integrated along the entire set, but I see no sense in doing that when the Nerd Font Mono families already require extensive tweaking to make them work proper in a pure monospace environment.

Modified E0D1 could also be used as a "Slim" variant of E0D1, in case there are people who think that glyph by itself takes up a bit too much space, but I don't see much sense including that in variable-width monospace Nerd Fonts.

Hebgbs commented 5 years ago

In case someone is already reading this, I had modified the OP quite a fair bit since initial posting, since I couldn't really make up my mind on how to convey my solution.

ryanoasis commented 5 years ago

Thanks @Hebgbs good thoughts here. I did just read it in its entirety but to be honest I'll need to parse through your thoughts again.. :blush:

Hebgbs commented 5 years ago

I've been playing with Nerd Fonts for some time and encountered issues I could not easily resolve because I'm not the sort of hacker man that most people using your suite of fonts are. Apologies for not following up with the previous issue I submitted earlier, kinda just lost interest I guess.

The powerline glyphs are awesome and all, they just tend to be difficult to use in zsh for right prompt if one doesn't use a monospace font (Nerd Font Mono), and I don't think a lot of terminal emulators for Linux (my preferred platform) allow for using two fonts at once, or it my solution does, which is Terminator then I don't know how to do it.

I know there are some TEs that permit more than one font, iTerm for Apple OS X I believe is one. But the core issue at hand is that people shouldn't have to hack around a problem using shape glyphs the likes of what you made as Powerline in their TE when the shape glyphs should always be monospace to begin with. I do hope you consider what I had addressed as a new font family, or at the very least fix the variable-width monospace fonts to not be so difficult to use. A re-implementation of Powerline with "Wide" shapes which require two characters could lend to some creativity with half-shapes and also partially, or in some instances fully fix the issue of glyphs not lining up.

Jaykul commented 5 years ago

I understand why you want the monospace PowerLine characters -- even on a terminal that renders non-monospaced characters fine, they throw off the width of the line and make it impossible to line up two lines of text, for instance...

What I don't understand is why you would want everything else to be non-monospaced glyphs, in a situation where non-monospaced characters don't work.

Hebgbs commented 5 years ago

Well, at least in my instance the TE I am using renders non-monospace characters as double characters, and I don't believe it would be such a problem so long I account for spacing. With the non-mono fonts, Terminator renders that perfectly fine as a double-width character. but then I want to use something like a triangle and it never renders with correct spacing on the right prompt in zsh, and it doesn't even render that right on the left prompt.

The ONLY characters which render correctly for segment separators are E0B0-B7, E0D2 and E0D4. (Even though E0B0-B3 are the best fit, just tried D2 and D4, they work alright with mild spacing issues.)

I want to be able to use the other Powerline characters, but I cannot without playing with spacing, which is pretty jank on the left prompt and not at all suitable for right prompt. Even though I just said variable-width characters appear as double width in Terminator, proper spacing is still somehow basically impossible for right prompt.

If you want, I can try to get some screen captures later showing exactly the issues I am receiving. It's not setup specific, any config will exhibit these issues.

As for why I like the non-mono fonts. it's because they have bigger icons since they are not limited to single-width, basically. But in a TTY I use fbterm which also lets me define a separate, pure monospace font. So atm I am getting the best of both worlds if I settle with relatively sane defaults.

PatTheMav commented 4 years ago

@Jaykul I believe I stumbled upon a much "simpler" use case for this feature:

I patch my own fonts to avoid license issues and I've found that using double-width glyphs worked fine in e.g. Terminal.app for prompts like Powerlevel10k and the defaults powerline/airline glyphs work fine in vim.

That is until the (optional) additional power line glyphs are chosen, which - for some reason - are about 1.5x to 2x wider than the default glyphs and break the layout.

Building a true monospaced font fixes that particular issue, but many glyphs are now "too small" to retain their features on lower font sizes (e.g. NPM logo glyph).

It seems to me that the power line default glyphs stay monospaced, but the optional ones are stretched, which leads to undesired layout behavior.

DLWood1001 commented 4 years ago

@PatTheMav I noticed this issue with E0B8, E0BA, E0BC, E0BE. These are the corner triangle powerline extra glyphs. In the 'non-mono' font variants they are double sized compared to the 'mono'. Oddly, the normal powerline fonts are correct width in both. Is this what this bug was in regards to?

PatTheMav commented 4 years ago

@DLWood1001 I believe so - the observed behaviour is that the default arrowhead glyphs have the same width for both variants and thus work as expected, the triangle ones do not.

DLWood1001 commented 4 years ago

@PatTheMav You mentioned that you patch your own fonts. Is it possible to work around this issue with the powerline extra glyphs via manual patching? I haven't looked too deep at the source/features of the font-patch utility yet.

PatTheMav commented 4 years ago

It's probably possible, but I'm not doing a lot of "manual" adjustments, as all I needed was available glyphs added to SF Mono as-is (which can't be distributed due to its license).

Hebgbs commented 3 years ago

@PatTheMav ~ Is this what this bug was in regards to?

Yes. That probably explains it better. All the shape and decorative elements of Powerline-style fonts ought to be just pure monospace, but I can understand how that would mess with people's setups. The resolution I want is more shape options, even if I do end up needing to use more symbols for an effect I am going for if not a whole separate family because certain cases, such as right-side prompt rendering do not appear correct with some shapes, which limits creativity for people who want to apply flourishes and embellishments in their shell and have it appear correctly.

Finii commented 1 year ago

Let me comment while I read...

The handling of monospaced changed a bit in contrast to what it was when this post hast been written initially. In fact there are now three variants, but only two are existing as prepatched (yet, that might change with v3.0.0):

I believe in all these fonts the powerline symbols are forced to 'one cell width'. That is not entirely true. Some powerline glyphs like 'flames' look extremely compressed in one cell, so they are scaled to 'two width' in certain situations. These are: Flames, Waveform, TopTriangles, and BottomTriangles.

For all 3 Nerd Font variants the "how big could a cell be" is determined, even for Propo, even if the sourcefont is proportional. That is used for the powerline glyphs. I also remember that the right hand side glyphs were very strange, that has also been fixed.

This means, I guess what you suggest as Nerd Font Power Mono is in fact already existing ... in all patched fonts.

Half-width variants and extra fonts would probably possible, but that seems extremely niche? Later on you never mention them anymore, so I guess you dropped that idea.

@Hebgbs https://github.com/ryanoasis/nerd-fonts/issues/362#issuecomment-517947075 This should be fixed.

@DLWood1001 https://github.com/ryanoasis/nerd-fonts/issues/362#issuecomment-655048095 At the moment they are specifically scales to 2 width, I never used them. If you say they should be 1 width the change is trivial. I set them to '2' along with Flames and Waveform. Maybe that was an error?

Ok.

I guess this is fixed and close this now. Update to v2.3.3 ;-)

If the Top/Bottom Triangles should be rather 1 than 2 cells wide, let me know (@DLWood1001). Maybe show a screenshot of your prompt, I'm interested to see them used.

More information

Edit: add two more links

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a new issue, complete the issue template with all the details necessary to reproduce, and mention this issue as reference.