jessedoyle / prawn-icon

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

Text color is not being honored when <icon> is used #52

Closed vanboom closed 2 years ago

vanboom commented 2 years ago
icon 'Test: <icon size="6">fas-helicopter</icon>', size: 9, color: '555555', inline_format: true

The color value does not appear to be effective.

Putting the color in the element works for the icon but not the text...

icon 'Test: <icon size="6" color='555555'>fas-helicopter</icon>', size: 9, color: '555555', inline_format: true

Thanks for a great gem - Prawn is extremely complicated to me but I will try to PR if I can.

vanboom commented 2 years ago

This appears to be an issue with v1.4.0 which I am using to use the old FontAwesome icon set.

   def inline_icon(text, opts = {})
        parsed = Icon::Parser.format(self, text)
        content = Text::Formatted::Parser.format(parsed)
        box_options = opts.merge(
          inline_format: true,
          document: self,
          at: [bounds.left, cursor]
        )
        icon_box(content, box_options)
      end

Closing since this does not apply to the latest version.

jessedoyle commented 2 years ago

Hi @vanboom! Thanks for the interest in Prawn::Icon!

Unfortunately we no longer support the 1.X series of the gem, so the suggestion would be to update to a later version of the gem.

With that being said, if you still wish to use the older FontAwesome 4 icon sets, you may have some luck by providing/configuring your own font TTF and legend files for the older icon set using the latest gem version:

Prawn::Icon.configure do |config|
  config.font_directory = '/path/to/font/directory'
end

# ls -R /path/to/font/directory
# ./fa4
# |-- fontawesome.ttf # located here: https://github.com/jessedoyle/prawn-icon/blob/v1.4.0/data/fonts/fa/fontawesome.ttf
# |-- fa4.yml         # located here: https://github.com/jessedoyle/prawn-icon/blob/v1.4.0/data/fonts/fa/fa.yml#L2, change the `fa` key on line 2 to `fa4`.

I haven't tried this out, but it should work if you prefix the icon with fa4-, i.e. fa4-arrows.

vanboom commented 2 years ago

Thanks - yes I noticed our version after posting the issue. We were able to upgrade to the latest version. Thanks for your work on this gem it is very handy.