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

Update Enum.swift #230

Closed
arashetm opened this issue Sep 30, 2019 · 17 comments
Closed

Update Enum.swift #230

arashetm opened this issue Sep 30, 2019 · 17 comments

Comments

@arashetm
Copy link

Hi
How can I update Enum.swift?!
I want to use pro style of fontawesome but one of icons that I want is missed in the Enum (fa-text).
Could you please help me?
Thanks

@foscomputerservices
Copy link

I too am encountering this issue. There are some icons that a pro-only. Examples include: fa-text, fa-user-headset, fa-users-class.

These icons do not appear to be listed in Font-Awesome/metadata/icons.json file, so when generating updates to Enum.swift, they do not appear.

Are there any suggestions how we can specify these icons other than forking the repository and manually adding them by hand to Enum.swift?

I would be happy to contribute a pull request if there is an idea on how support should be incorporated into the current design.

Thank you!

@stale
Copy link

stale bot commented Nov 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 8, 2019
@foscomputerservices
Copy link

Ping!

@stale stale bot removed the stale label Nov 8, 2019
@stale
Copy link

stale bot commented Dec 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 8, 2019
@foscomputerservices
Copy link

Hello. is it possible that this project is no longer being maintained? I'm more than happy to help!

@stale stale bot removed the stale label Dec 12, 2019
@thii thii added the question label Dec 19, 2019
@thii
Copy link
Owner

thii commented Dec 19, 2019

To update to a new font version, run:

bundle exec fastlane update_font version:x.y.z

where x.y.z is the font version.

Enum.swift is generated by codegen.swift. Please take a look at it.

@foscomputerservices
Copy link

@thii, thank you for your response! Completely understand about how to update it from those instructions in the readme. However the question that was asked was:

Are there any suggestions how we can specify these {pro-only} icons other than forking the repository and manually adding them by hand to Enum.swift?

I have done exactly this for my own forked copy of the project. I was simply wondering what the ongoing strategy was to:

  1. Include/update the pro-only styles and icons
  2. Keep the non-forked project up-to-date as, obviously, I cannot run: bundle exec fastlane release version:x.y.z

I'm guessing that the answer is to keep a fork and merge any changes from the master repository into my fork over time.

Thank you!

@stale
Copy link

stale bot commented Jan 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 19, 2020
@thii thii added help wanted and removed stale labels Jan 19, 2020
@MoElnaggar14
Copy link
Contributor

@thii how I can update The Enum, i installed Pod through Podfile

@thii
Copy link
Owner

thii commented Feb 19, 2020

Run ./codegen.swift.

@MoElnaggar14
Copy link
Contributor

the Pod files don't contain ./codegen.swift

@mralexhay
Copy link

Also wondering how to update the enum to include pro symbols

@ghost
Copy link

ghost commented Mar 27, 2020

Edit: Sorry, had to delete my previous comment as I ran into some problems with it. But they are solved, so the following works.

I ran into the same issue today and solved it like this. It's very hacky and there is definitely a more elegant way to properly support this in the future. But it works as a workaround for now.

  1. Clone the https://github.com/thii/FontAwesome.swift/ repository to your local machine

  2. When you are using Cocoapods: Include your local pod in your app instead of the hosted one. This will then automatically include the updated Enum.swift in your app once you are done with step 10.

  3. Until @thii accepts add duotone style decoding #247, you need to apply this patch manually to your local codegen.swift. If you do not do this, you will get an error in step 8 and you will not get the pro icon enum.

  4. You need to patch FontAwesome.swift to include the .duotone style:

     public enum FontAwesomeStyle: String {
         case solid
         /// WARNING: Font Awesome Free doesn't include a Light or Duotone variant. Using this with Free will fallback to Regular.
         case light
         case regular
         case brands
         case duotone
         
         func fontName() -> String {
             switch self {
             case .solid:
                 return FontAwesomeConfig.usesProFonts ? "FontAwesome5Pro-Solid" : "FontAwesome5Free-Solid"
             case .light:
                 return FontAwesomeConfig.usesProFonts ? "FontAwesome5Pro-Light" : "FontAwesome5Free-Regular"
             case .regular:
                 return FontAwesomeConfig.usesProFonts ? "FontAwesome5Pro-Regular" : "FontAwesome5Free-Regular"
             case .duotone:
                 return  FontAwesomeConfig.usesProFonts ? "FontAwesome5Duotone-Solid" : "FontAwesome5Free-Regular"
             case .brands:
                 return "FontAwesome5Brands-Regular"
             }
         }
    
         func fontFilename() -> String {
             switch self {
             case .solid:
                 return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro-Solid-900" : "Font Awesome 5 Free-Solid-900"
             case .light:
                 return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro-Light-300" : "Font Awesome 5 Free-Regular-400"
             case .regular:
                 return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro-Regular-400" : "Font Awesome 5 Free-Regular-400"
             case .duotone:
                 return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Duotone-Solid-900" : "Font Awesome 5 Free-Regular-400"
             case .brands:
                 return "Font Awesome 5 Brands-Regular-400"
             }
         }
    
         func fontFamilyName() -> String {
             switch self {
             case .brands:
                 return "Font Awesome 5 Brands"
             case .regular,
                  .light,
                  .solid,
                  .duotone:
                 return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro" : "Font Awesome 5 Free"
             }
         }
     }
    

Note: You will not get duotone rendering with this! This is another issue #223 that needs to be solved eventually. We just need to support the duotone style formally, otherwise the enum with generate errors.

  1. Download the current Pro fonts from https://github.com/FortAwesome/Font-Awesome-Pro to your local machine. You will need a valid license which includes access to this private repository to do so.
  2. Change to the directory where the FA Pro fonts reside and copy all files from the metadata directory to FortAwesome/Font-Awesome/metadata in your local https://github.com/thii/FontAwesome.swift/ repository, overwriting the files that reside there. The most important file here is icons.json.
  3. Open a shell and change to the root directory of your local repository
  4. Run swift codegen.swift from the command line there
  5. You now have an Enum.swift in your repository that has all the Pro icons
  6. Include this in your app and enjoy all FA Pro icons there.

Important: You probably should not commit to this repo from your local copy now as this would add some licensed FA Pro files to the public repo.

@valexa
Copy link

valexa commented Mar 27, 2020

In addition to the instructions above here is a gist with the Enum.swift file all update with the pro font https://gist.github.com/valexa/e206ad23c962b184484e1a085b9c5717

@MoElnaggar14
Copy link
Contributor

I already updated in this PR

@ivanorotondo
Copy link

I solved it following @ghowen instructions but with a couple of differences: it results the codegen.swift file is now called main.swift and you can find it in /tools folder. Plus, you better move it in the root project folder because there's some inconsistency with paths. After launching swift main.swift it created the new Enum.swift file in /FontAwesome and I could use it in my project. Beware there's an icon called "repeat" which conflicts with swift code (is a reserved word) but deleting the rows involved is enough to solve it. Cheers

@MatrixSenpai
Copy link
Collaborator

You should use swift run tools from the root directory instead

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

8 participants