jessedoyle / prawn-icon

Easy icons for Prawn.
Other
31 stars 15 forks source link

FontAwesome 5 #33

Closed jessedoyle closed 6 years ago

jessedoyle commented 6 years ago
aoyawale commented 6 years ago

thanks! I'm going to try it out but, how do I build this project? I apologize, I'm still new to ruby/rake things.

jessedoyle commented 6 years ago

No need to apologize @jlozadad! It really depends on how you're using prawn/icon.

One way that you could build and test the gem is by cloning the branch and installing locally:

git clone git@github.com:jessedoyle/prawn-icon.git
cd prawn-icon
git checkout fa-5
gem build prawn-icon.gemspec
gem install prawn-icon-2.0.0.gem

Once installed, you can try running some code in an interactive Ruby shell:

irb

(from within irb)

require 'prawn/icon'

Prawn::Document.generate('fontawesome-5.pdf') do |pdf|
  pdf.icon 'fas-bomb', size: 80
end

If you've cloned the repository, you can also run the following commands in the root directory to generate icon mapping PDFs:

bundle install
bundle exec rake legend # this will generate a few .pdf files in the project directory
aoyawale commented 6 years ago

thanks so much for the information! I just builded it and used bundle install to generate the PDF's. Looks like the new icons are there!

berzley commented 6 years ago

Would it be possible to add the fa-* icons back in? Although they are deprecated in FA5, they are still usable. This would allow for some backwards comparability as users of prawn-icon begin migrating to the updated version.

jessedoyle commented 6 years ago

@berzley - I'd love to have done this as a non-breaking change, but it appeared that there were only a few options, and I thought both would lead to issues:

  1. Keep the last FontAwesome 4 .ttf and .yml files around for a few releases and any fa-* references would still render the old FontAwesome 4 icons. The issue with this is that it would be confusing - if I were new to prawn/icon I'd assume that I could simply bundle update prawn-icon and reference fa-football-ball and be off and running with the new FontAwesome 5 icons. Unfortunately this would not work at all.

  2. Write a wrapper shim that was able to dynamically interpret fa-* references and properly map them to their corresponding icons in either the regular, solid or brands font styles. From my understanding, this is what the official FontAwesome shim does. I may be wrong here, but I think this would work in the browser because the shim translates all the icons to SVG (which live in the javascript), I don't think this is possible with the .ttf files as we need to know a unicode value as well as the icon specifier to render an icon (i.e. there's likely ambiguity in some cases).

Fundamentally, the issue is that the FontAwesome team decided to split out their icons into 3 different font files (brands, regular and solid), each with their own set of icons and unicode mappings.

Ultimately, I decided both options above are not ideal and creating the fas-*, fab-* and far-* specifiers is the best route going forward. This is why we had to release version 2.0.0 as this is very clearly a non-backwards compatible change.

Of course, any pull requests are more than welcome! It's very possible that I'm mistaken, or that there's a simple mechanism for backwards compatibility that I overlooked!

With that being said, I could be convinced for option (1) above if there was enough demand. My concern is that it would cause confusion among prawn/icon users.

berzley commented 6 years ago

I completely understand - I hadn't dug too deep into the project code to see the full extent of the separation at that level. My experience primarily lies with Font Awesome's CSS usage and the depth of the separation wasn't as clear to me.

If I see a way to contribute a solution to my request I'll implement and issue a pull request.

Regardless - I'm happy to see FontAwesome 5 implemented here and am already using it.

jessedoyle commented 6 years ago

@berzley - I'll still keep looking into this - but it may take a few weeks or more. The more I think about it, the more I think option (2) may be possible.

We can definitely release a 1.5.0 version of this gem as an interim release if we can come up with a solution. Again - if anyone has ideas, PRs will be accepted!

jessedoyle commented 6 years ago

@berzley - It's far from perfect, but I started taking a look at a compatibility shim. Here's my initial work: https://github.com/jessedoyle/prawn-icon/tree/fa-4-compat.