Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🙏🏻 Is it possible to "center" glyphs which overlap a single cell by padding them? #1330

Open
3 tasks done
rivy opened this issue Aug 2, 2023 · 3 comments
Open
3 tasks done

Comments

@rivy
Copy link

rivy commented Aug 2, 2023

Requirements

  • I have searched the issues for my request and found nothing related and/or helpful
  • I have searched the FAQ for help
  • I have searched the Wiki for help

Is your feature request related to a problem? Please describe.

When using glyphs which overlap to the next cell, it is difficult to visually align columns. Subsequent lines with vertically aligned glyphs will often seem slightly askew visually.

The vertical size changes to the glyphs in the "FONT_NAME Nerd Font" and "FONT_NAME Nerd Font Propo" seems to have settled into a very aesthetically appealing form.

It just horizontally challenged, especially for table-type alignments.

Describe the solution you'd like

Would it be possible to visually center the glyphs within the two-cell-width space by adding a left padding, essentially treating them as pseudo two-cell-width characters? By forcing the glyph into the center portion of two cells, it would make vertical alignment much more aesthetic.

For compatibility, the characters would still be "narrow", being seen as single cell width, allowing the current usual practice of adding a single space (" ") after the glyph to continue to work for display alignment of other characters.

Possibly name the font variant something like "FONT_NAME Nerd Font Wide"?

This, with some obvious documentation of the difference between default/Mono/Propo/Wide variants, might solve more of the character alignment complaints.

Thanks for the consideration.

@Finii
Copy link
Collaborator

Finii commented Aug 3, 2023

Thanks for the suggestion.

Code-wise what you propose seems to be this:

index 247c28367..29eeb0fdd 100755
--- a/font-patcher
+++ b/font-patcher
@@ -1448,7 +1448,7 @@ class font_patcher:
                 x_align_distance = self.font_dim['xmin'] - sym_dim['xmin']
                 if sym_attr['align'] == 'c':
                     # Center align
-                    x_align_distance += (self.font_dim['width'] / 2) - (sym_dim['width'] / 2)
+                    x_align_distance += (self.font_dim['width'] * self.get_target_width(stretch) / 2) - (sym_dim['width'] / 2)
                 elif sym_attr['align'] == 'r':
                     # Right align
                     x_align_distance += self.font_dim['width'] * self.get_target_width(stretch) - sym_dim['width']

That is just superficially tested code, the scale rules can be quite complex and the impact on other scale paradigms has to be evaluated.

Do you propose an option for self patching people, or a forth variant of pre-patched fonts? The later of course will blow up the release by 1/3 in size 😒

might solve more of the character alignment complaints.

I am not aware of any?

One use of the icons in for directory listings, like ls (i.e. exa).
Here clearly everything is left aligned and center aligned icons might not look very good.

image
Image taken from https://the.exa.website/features/icons

The current strategy is to center the icon in one (the left) cell. If it is wider than one cell it is still centered in the left/first cell, but on the other hand it is not allowed to protrude leftward into the previous cell, so in fact it is left aligned when the size is wider than one cell.

@rivy
Copy link
Author

rivy commented Aug 8, 2023

@Finii , thanks for the response.

The current strategy of left-alignment for "plus-size" icons looks generally ok; but the precise left-alignment with the slightly ragged right edge is a bit visually jarring (such as between the zip icons those surrounding them vertically), distracting slightly from the surrounding content.

I'm not sure it can be fixed, but my thought was that centering the "plus-sized" glyphs, or maybe all the glyphs?, within a double-wide space would decrease any visual inconsistency, with symmetry of the horizontal padding. This would be similar to the vertical centerline symmetry present in the rest of the non-glyph "narrow" characters. And I believe the double-wide emojis are similarly centered over two characters widths.

But, given the variation in icons and icon widths, I'm not sure that it would actually be a net benefit. It might actually have a similar amount of distracting visual variability. Unfortunately, I'm not currently experienced enough with fonts and font patching to perform the experiments.

Ideally, it would be great to be able to pick horizontally-centered "narrow" or "wide" variants, similar to emojis, but, from my reading about unicode, that seems like it might be an impossible task.


If done, I would think enabling self-patching would be appropriate if/until it becomes a popular variant.

@Finii
Copy link
Collaborator

Finii commented Mar 28, 2024

Note to self:

If done, I would think enabling self-patching would be appropriate if/until it becomes a popular variant.

This is the key point of this Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants