diff --git a/CHANGELOG.md b/CHANGELOG.md index add17bc..19b35e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 4.1.0 - December 12, 2024 + +* Add a `size_mode` option to the `icon` method that scales the size of the rendered icon to fit within the requested value. + +Please see the documentation [here](https://github.com/jessedoyle/prawn-icon?tab=readme-ov-file#icon-size-mode) for further information. Thanks @pepijnve! [Pull Request](https://github.com/jessedoyle/prawn-icon/pull/65) + # 4.0.0 - November 25, 2024 * **breaking change** - Update from FontAwesome 5.11.2 to 6.7.1. Please see the notes [here](https://fontawesome.com/changelog#v6-0-0) for information related to changed or removed icons in the set. Thanks @pepijnve! [Pull Request](https://github.com/jessedoyle/prawn-icon/pull/62) diff --git a/README.md b/README.md index bddc0c0..423a5a4 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ If you wish to fork this repository and add a new font, you'll likely need to su ## Examples -A Rake task is included to generate documents that display each icon and it's corresponding icon key. +A Rake task is included to generate documents that display each icon and its corresponding icon key. The command: @@ -121,6 +121,23 @@ Prawn::Icon.configure do |config| end ``` +## Icon Size Mode + +Some font families (in particular those of FontAwesome 6) define metrics that may render an icon at a size larger than requested (as described [here](https://github.com/jessedoyle/prawn-icon/pull/62#issuecomment-2501622305)). + +Prawn::Icon provides a `size_mode` parameter that can be utilized to control this behaviour: + +* `size_mode: :font_size` (**default**) - Renders the icon at a size calculated via font metrics. This may result in an icon that renders larger than requested due to ascender/descender metrics. +* `size_mode: :icon_height` - Renders the icon at a size scaled down to the requested size. + +You can specify the size mode as follows: + +```ruby +Prawn::Document.generate('size_mode.pdf') do |pdf| + pdf.icon 'far-circle', size: 100, size_mode: :icon_height +end +``` + ## Contributing I'll gladly accept pull requests that are well tested for any bug found in Prawn::Icon. diff --git a/lib/prawn/icon/version.rb b/lib/prawn/icon/version.rb index e23849a..c1ba123 100644 --- a/lib/prawn/icon/version.rb +++ b/lib/prawn/icon/version.rb @@ -8,6 +8,6 @@ module Prawn class Icon - VERSION = '4.0.0' + VERSION = '4.1.0' end end