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

AttributeError when patching with py3 version script #79

Closed
shellkr opened this issue Apr 27, 2016 · 11 comments
Closed

AttributeError when patching with py3 version script #79

shellkr opened this issue Apr 27, 2016 · 11 comments
Labels
Milestone

Comments

@shellkr
Copy link

shellkr commented Apr 27, 2016

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
@ryanoasis
Copy link
Owner

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

@kazuoteramoto
Copy link

Looks like the problem was introduced in 019bf46 .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:

@shellkr
Copy link
Author

shellkr commented Apr 29, 2016

Can confirm that the patch works. No more errors.

@shellkr
Copy link
Author

shellkr commented Apr 30, 2016

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

@ryanoasis
Copy link
Owner

@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 😅

@shellkr
Copy link
Author

shellkr commented Apr 30, 2016

@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.

@ryanoasis
Copy link
Owner

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

@shellkr
Copy link
Author

shellkr commented Apr 30, 2016

Ok, seems like the issue is mainly with Urxvt. FortAwesome/Font-Awesome#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

@ryanoasis
Copy link
Owner

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.

@ryanoasis ryanoasis changed the title AtributeError when patching fontawesome, powerlineextra and octicons AtributeError when patching with py3 version script May 14, 2016
@ryanoasis ryanoasis changed the title AtributeError when patching with py3 version script AttributeError when patching with py3 version script May 14, 2016
@ryanoasis ryanoasis added this to the v0.8.0 milestone May 15, 2016
@ryanoasis
Copy link
Owner

@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 😄

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants