prawn-rails 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '038a7bc1fd0cf46c805b37358ca5f43f97ea61bd3a9bb2a5f57c93b063735faf'
4
- data.tar.gz: 44842dfeddbb4e8c525767bd2838ab732d92d350aed9e9d8b8d44c0af14e26d6
3
+ metadata.gz: 98ab6c1736809af9812490c14ccc652d5835462fe406116ea1d2dbb1e5c985a1
4
+ data.tar.gz: b561b81198ec9b3ddea346f4ade6be71f684a280fd00068c286c675748733554
5
5
  SHA512:
6
- metadata.gz: 32c30aa630ddba6fb25c4e92520f2a61ed99ac43159729b4064bddbe56ae74e04b18d8823a58020a37f897b3fa281ae049add79ad7e5caf39ad8ed471ba6a289
7
- data.tar.gz: 16909da459d44bedbe4466c42b6ee080231d7a714f2268227a58e64cb825de1f0dfd5dcc4b9f836839b4520b5e3ae6e2b2463c465ddfe2ded71c792d7d5b6376
6
+ metadata.gz: 1a33b34482d7a7aa9bf834695b684abcc51e3fa6e5808d8792a1cfee4160100885877f4a68eec4e81055b403c301f528567a810fec864e9911cd684b08ece7af
7
+ data.tar.gz: e5c0b84bb673f92dd211554cde2966d93d027242552c93cd6d124498b26ab9ec4448cc1f3afd22227b139e09a55bd5cce21b99e0895c63152cee4fdb76c48d3c
data/CHANGELOG.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Changelog
2
2
 
3
- * `Unreleased` - [View Diff](https://github.com/cortiz/prawn-rails/compare/v1.5.0...master)
3
+ * `Unreleased` - [View Diff](https://github.com/cortiz/prawn-rails/compare/v1.6.0...master)
4
4
  - Nothing yet
5
5
 
6
+ * `v1.6.0` - [View Diff](https://github.com/cortiz/prawn-rails/compare/v1.5.0...v1.6.0)
7
+ - [#55](https://github.com/cortiz/prawn-rails/pull/55) - Add config options `additional_fonts` and `default_font_name`
8
+
6
9
  * `v1.5.0` - [View Diff](https://github.com/cortiz/prawn-rails/compare/v1.4.2...v1.5.0)
7
10
  - [#52](https://github.com/cortiz/prawn-rails/pull/52) - Add active_support as a dependency and use the active_support lazy load hooks
8
11
  - [#51](https://github.com/cortiz/prawn-rails/pull/51) - Remove usage of openstruct for config object
data/README.md CHANGED
@@ -60,9 +60,21 @@ Add a `prawn-rails.rb` config to your Rails app under `config/initializers` like
60
60
 
61
61
  ```ruby
62
62
  PrawnRails.config do |config|
63
+ # Prawn::Document options
63
64
  config.page_layout = :portrait
64
65
  config.page_size = "A4"
65
66
  config.skip_page_creation = false
67
+
68
+ # PrawnRails options
69
+ config.additional_fonts = {
70
+ "some-custom-font" => {
71
+ normal: Rails.root.join('app/assets/fonts/print/some-custom-font.ttf'),
72
+ italic: Rails.root.join('app/assets/fonts/print/some-custom-font-italic.ttf'),
73
+ bold: Rails.root.join('app/assets/fonts/print/some-custom-font-bold.ttf'),
74
+ bold_italic: Rails.root.join('app/assets/fonts/print/some-custom-font-bold-italic.ttf'),
75
+ },
76
+ }
77
+ config.default_font_name = "some-custom-font"
66
78
  end
67
79
  ```
68
80
 
@@ -26,6 +26,8 @@ module PrawnRails
26
26
  page_layout: :portrait,
27
27
  page_size: "A4",
28
28
  skip_page_creation: false,
29
+ additional_fonts: nil,
30
+ default_font_name: nil,
29
31
  )
30
32
 
31
33
  def config(&block)
@@ -4,7 +4,7 @@ require 'prawn/table'
4
4
  module PrawnRails
5
5
  class Document < Prawn::Document
6
6
  def initialize(options = {})
7
- options = PrawnRails.config.merge(options)
7
+ options = PrawnRails.config.except(:additional_fonts, :default_font_name).merge(options)
8
8
 
9
9
  super(options)
10
10
  end
@@ -16,5 +16,21 @@ module PrawnRails
16
16
  # To circumvent this situation, we call to_s on value, and delegate action to actual Prawn::Document
17
17
  super(value.to_s, options)
18
18
  end
19
+
20
+ def start_new_page(options = {})
21
+ return_val = super
22
+
23
+ if state.page_count == 1
24
+ if PrawnRails.config.additional_fonts
25
+ font_families.update(PrawnRails.config.additional_fonts)
26
+ end
27
+
28
+ if PrawnRails.config.default_font_name
29
+ font(PrawnRails.config.default_font_name)
30
+ end
31
+ end
32
+
33
+ return_val
34
+ end
19
35
  end
20
36
  end
@@ -1,3 +1,3 @@
1
1
  module PrawnRails
2
- VERSION = "1.5.0".freeze
2
+ VERSION = "1.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Ortiz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-09-12 00:00:00.000000000 Z
12
+ date: 2024-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prawn