Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Prawn::Icon provides a simple mechanism for rendering icons and icon fonts from within Prawn.
The following icon fonts ship with Prawn::Icon:
Prawn::Icon was originally written by Jesse Doyle.
Prawn::Icon is distributed via RubyGems. You can install it with the following command:
gem install prawn-icon
Prawn::Icon was designed to have an API familiar to Prawn. A single icon may be rendered as such:
require 'prawn/icon'
Prawn::Document.generate('icons.pdf') do |pdf|
pdf.icon 'fas-beer', size: 60
end
produces:
You can also provide the inline_format: true
option to Prawn::Icon:
require 'prawn/icon'
Prawn::Document.generate('inline_icons.pdf') do |pdf|
pdf.icon 'Enjoy: <icon size="20" color="AAAAAA">fas-beer</icon>', inline_format: true
end
produces:
When using inline_format: true
, you may supply <icon>
tags with color
and size
attributes.
A table_icon
method may be called when creating a table's data array to render icons within a table cell:
require 'prawn/icon'
require 'prawn/table'
Prawn::Document.generate('table_icons.pdf') do |pdf|
data = [
# Explicit brackets must be used here
[pdf.table_icon('fas-birthday-cake'), 'Cake'],
['is', 'Great!']
]
pdf.table(data) # => (2 x 2 table)
end
Note that the table_icon
method supports the inline_format: true
option to create multiple icons within a cell.
Prawn::Icon uses the prefix of an icon key to determine which font family is used to render a particular icon.
Currently supported prefixes include:
fab
- FontAwesome Brands (eg. fab-amazon
).far
- FontAwesome Regular (eg. far-address-book
).fas
- FontAwesome Solid (eg. fas-location-arrow
).mdi
- Material Design Icons (eg. mdi-beer
),fi
- Foundation Icons (eg. fi-compass
).pf
- PaymentFont (eg. pf-cash
).Prawn::Icon uses a "legend" to map icon keys to unicode characters that respresent a particular icon within the font file.
This legend is a standard .yml
file located within the font's directory.
If you wish to fork this repository and add a new font, you'll likely need to supply a corresponding legend file. Please see the current legend files within the data/fonts
directory for examples.
A Rake task is included to generate documents that display each icon and it's corresponding icon key.
The command:
rake legend
should generate these files when run from Prawn::Icon's gem directory.
You can optionally configure Prawn::Icon to use an alternate data directory for font files.
Prawn::Icon.configure do |config|
config.font_directory = '/path/to/my/fonts'
end
I'll gladly accept pull requests that are well tested for any bug found in Prawn::Icon.
If there is enough demand for including a particular icon font, I will also accept a pull request to include it in Prawn::Icon.
Prawn::Icon is licensed under the same terms that are used by Prawn.
You may choose between Matz's terms, the GPLv2, or GPLv3. For details, please see the LICENSE, GPLv2, and GPLv3 files.
FAQs
Unknown package
We found that prawn-icon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.