Gurupreet / FontAwesomeCompose

Font Awesome free icons pack available for Jetpack Compose ready to use.
169 stars 17 forks source link

FA Pro icons support #6

Open alexhayes opened 2 years ago

alexhayes commented 2 years ago

Firstly thanks for making this!

I'm wondering, it says to get in contact if we're looking for FA Pro icon support. Is this something you plan to add or is there some way for it to be enabled?

Gurupreet commented 2 years ago

Hi @alexhayes Thanks for raising it. I will need to sort out the process of importing pro icons for people who have bought it already. Let me see how to proceed and would definitely will be adding it in coming future.

alexhayes commented 2 years ago

Let me know if you'd like me to explore how this could be done.

Gurupreet commented 2 years ago

Hi @alexhayes please feel free to explore and raise any documentation of PR to support :)

alexhayes commented 2 years ago

Hi @Gurupreet after investigating this I don't believe this is going to be possible using the current approach of output vals in the FaIcons object. The problem is that with all the icons in Font Awesome 5 Pro the generated FaIcons object is too large and results in a "Code too large" compilation error - as described in this StackOverflow post.

I investigated various alternatives, such as perhaps using a properties file, using XML or perhaps even using protobufs as a faster alternative to XML (it's a massive XML file!). All require a large refactor that would change the API considerably and thus I didn't think that was appropriate.

Perhaps the approach that would be easiest for users of this library would be the one used in the FASwiftUI where the library opens up the icons.json file supplied as part of the Font Awesome download. For Pro icons this is a 14MB json file!

Using jq this file can be reduced down to 166KB as follows;

jq -c 'del(.[].changes, .[].ligatures, .[].search, .[].label, .[].voted, .[].svg, .[].free)' icons.json > icons-minified.json

However, note currently with the feature set of FASwiftUI it requires to include the search and label attributes in the JSON, which, when minified is 365K (not great, but much better than 14MB!).

Outside of the above, in order to offer Pro support a mechanism to allow users of this library to supply their own font files will need to be implemented because the Font Awesome 5 license won't allow the fonts to be shipped in this library. This appears to be trivial and will likely come down to instructions in the README, but really depends on the approach taken in any refactor.

Gurupreet commented 2 years ago

ahh bummer! is there a reason PRO icons are too large. I have updated to latest version for compose and kotlin as well. Not sure if that will be helpful.

alexhayes commented 2 years ago

ahh bummer! is there a reason PRO icons are too large. I have updated to latest version for compose and kotlin as well. Not sure if that will be helpful.

The reason is there are so many icons that the class gets too large and can't be compiled - the issue is described here.

Unfortunately the version of Kotlin and Compose won't have any bearing on it.