Nerd-fonts: AttributeError when patching with py3 version script

Created on 27 Apr 2016  Â·  10Comments  Â·  Source: ryanoasis/nerd-fonts

I am trying to patch PragmataPro with --fontawesome, --powerlineextra and --octicon but it fails. If I only try --powerline and --pomicons it works.

Coomand I run: fontforge -script font-patcher-py3 $HOME/PragmataPro/PragmataPro.ttf --fontawesome --powerline --powerlineextra --pomicons --octicons

Which gives the traceback:

...
Traceback (most recent call last):
File "font-patcher-py3", line 467, in <module>
copy_glyphs(sourceFont, sourceFontFontAwesomeStart, sourceFontFontAwesomeEnd, 
fontawesome, symbolsFontAwesomeRangeStart, symbolsFontAwesomeRangeEnd, True)
File "font-patcher-py3", line 343, in copy_glyphs
copiedToSlot = str(sym_glyph.str)
AttributeError: 'fontforge.glyph' object has no attribute 'str'

Similar error if I remove --fontawesome for the other flags.

My Setup

  • _PragmataPro, Knack Regular Nerd Font Complete Mono.ttf_
  • _Arch Linux, Urxvt, Zsh, libfontforge 20150928 and libfontforge 20160427_
âš  bug

All 10 comments

Hey, sorry I just haven't had time to look into this but I promise you I will. Thanks :+1:

Looks like the problem was introduced in 019bf46269e0b7598eb380d151c263e67488acec .unicode is the unicode code point of glyph not a unicode encoded string.

If you apply this sees to work

diff --git i/font-patcher-py3 w/font-patcher-py3
index c2392c2..849ad80 100755
--- i/font-patcher-py3
+++ w/font-patcher-py3
@@ -340,7 +340,7 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
             if exactEncoding:
                 # use the exact same hex values for the source font as for the symbol font
                 currentSourceFontGlyph = sym_glyph.encoding
-                copiedToSlot = str(sym_glyph.str)
+                copiedToSlot = str(sym_glyph.unicode)
             else:
                 # use source font defined hex values based on passed in start and end
                 # convince that this string really is a hex:

Can confirm that the patch works. No more errors.

However the patching doesn't seem to have worked. The powerline is not in sync and FontAwesome is not shown when patching PragmataPro. As shown in the screenshot below.

screenshot

When I tried with Knack it powerline worked better but still no FontAwesome.

screenshot2

@shellkr @kazuoteramoto Thanks for testing it out and the info here.

Seems that I was warned about 2to3 changing unicode to str (see #49) so my bad there.

I can confirm the same error, but the change @kazuoteramoto pointed out seems to work for me:

fontforge -script font-patcher-py3 ../temp/nerd-fonts/PragmataPro.ttf --powerline --powerlineextra --fontawesome

selection_29_04_16_21 05 59_122x41_001

granted i just copy and pasted the literal characters directly into the terminal :sweat_smile:

@ryanoasis What terminal is that? And you can see the powerline is a bit off in yours too. If you have a terminal which supports fontconfig it will look in all your fonts for glyphs. So you only need one font among all that is okay and it will work. It might not be the patched font you see in that image.

You are correct I need to make sure to clear out my patched fonts, I will try a less lazy test today.

Yeah the powerline symbols are definitely off

Ok, seems like the issue is mainly with Urxvt. https://github.com/FortAwesome/Font-Awesome/issues/3681. I got it working with the help of xft:SauceCodePro NF:pixelsize=9 as a fallback in my ~/.Xresources though. So it should be possible to get PragmataPro to work too somehow.. not sure how.

FontAwesome working

Going to make a bash script to do the 2to3 conversion because of this.

https://docs.python.org/2/library/2to3.html#to3-fixers

unicode
Renames unicode to str.

@shellkr If you are still having trouble patching PragmataPro or some other font issues feel free to open a separate issue. I am going to close this one (the AttributeError) for 0.8.0 release which I am almost done with :smile:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

logarytm picture logarytm  Â·  5Comments

alpertuna picture alpertuna  Â·  5Comments

boolim picture boolim  Â·  4Comments

Scrumplex picture Scrumplex  Â·  3Comments

aswinmohanme picture aswinmohanme  Â·  4Comments