Nerd-fonts: Some symbol glyphs show up as clipped.

Created on 17 Feb 2020  ·  4Comments  ·  Source: ryanoasis/nerd-fonts

🎯 Some symbole glyphs show up as clipped.

v2.0.0 of the _Ubuntu Mono Nerd Font Complete_ (double-width version, not mono-version) now truncates/clips certain glyphs.

An example is the battery glyph (which I think comes from font-awesome). The top of the image below represents the font generated by nerd-font v2.0.0... and the bottom image with the clipped glyphs represents the font generated using nerd-font v2.1.0

20200216T151526_maim

Using git-bisect, I was able to trace the problem to this commit: https://github.com/ryanoasis/nerd-fonts/pull/283/commits/cf625d46b5018615efc2049b3c52585443ef2eaa

After playing with the content of the commit against v2.1.0 of font-patcher, the following patch fixes the problem for me. It removes the negative bearings after setting the glyph width (undoing the partial change in that commit). But at this point, I'm out of my element. I'm not sure why this fix works for me, or if it introduces other problems.

diff --git a/font-patcher b/font-patcher
index b30b0a0c..8ec21c8f 100755
--- a/font-patcher
+++ b/font-patcher
@@ -762,10 +762,6 @@ class font_patcher:
             align_matrix = psMat.translate(x_align_distance, y_align_distance)
             self.sourceFont.transform(align_matrix)

-            # Ensure after horizontal adjustments and centering that the glyph
-            # does not overlap the bearings (edges)
-            self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph])
-
             # Needed for setting 'advance width' on each glyph so they do not overlap,
             # also ensures the font is considered monospaced on Windows by setting the
             # same width for all character glyphs. This needs to be done for all glyphs,
@@ -773,6 +769,10 @@ class font_patcher:
             # it should come after setting the glyph bearings
             self.set_glyph_width_mono(self.sourceFont[currentSourceFontGlyph])

+            # Ensure after horizontal adjustments and centering that the glyph
+            # does not overlap the bearings (edges)
+            self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph])
+
             # reset selection so iteration works properly @TODO fix? rookie misunderstanding?
             # This is likely needed because the selection was changed when the glyph was copy/pasted
             if symbolFontStart == 0:

The only clue for the change was a comment included in the original commit that suggested the opposite messed up glyph widths somehow...

# moved this after changing the bearings because i think it was
# messing up the glyph width to have it before
sourceFont[currentSourceFontGlyph].width = font_dim['width']

🔧 Your Setup

  • ArchLinux (i3wm)
  • SublimeText 3, i3blocks, xfce-terminal
  1. _Which font are you using?_
    Ubuntu Mono Nerd Font Complete.ttf (double-width)

  2. _Which terminal emulator are you using?_
    xfce4-terminal

  3. _Are you using OS X, Linux or Windows? And which specific version or distribution?_
    ArchLinux (latest updates)

⚠ bug

All 4 comments

thanks for all the details and even digging into this! really appreciate it

I just ran into the same issue myself, it seems some glyphs are slightly off center for some reasons, resulting in a clipping when rendered:
image

EDIT:
reverting to v2.0.0 fixed it for me too

why this seems to happen with people using arch linux and some twm?
Every nerd font except Fira Code is having the 'fi' ligature bug that shkws a telefone icon

On Sway and using Waybar I am having issue with Fira Code as well, although it is slightly better than Hack. (Notice the Battery icon "")
scrn-2020-05-25-13-31-01

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aswinmohanme picture aswinmohanme  ·  4Comments

alpertuna picture alpertuna  ·  5Comments

blueyed picture blueyed  ·  6Comments

maxwellmckinnon picture maxwellmckinnon  ·  3Comments

logarytm picture logarytm  ·  5Comments