prawn-icon 3.1.0 → 4.1.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.
@@ -54,7 +54,7 @@ module Prawn
54
54
  [Prawn::Icon - DEPRECATION WARNING]
55
55
  FontAwesome 4 icon was referenced as '#{old_key}'.
56
56
  Use the FontAwesome 5 icon '#{new_key}' instead.
57
- This compatibility layer will be removed in Prawn::Icon 4.0.0.
57
+ This compatibility layer will be removed in a future major release.
58
58
  DEPRECATION
59
59
  end
60
60
  end
@@ -225,7 +225,16 @@ module Prawn
225
225
 
226
226
  def render
227
227
  @pdf.font(@data.path) do
228
- @pdf.text @unicode, @options
228
+ opts = @options
229
+
230
+ if @options.fetch(:size_mode, :font_size) == :icon_height
231
+ requested_size = @options[:size] || @pdf.font_size
232
+ actual_height = @pdf.font.height_at(requested_size)
233
+ adjusted_size = requested_size / actual_height * requested_size
234
+ opts = opts.merge(size: adjusted_size)
235
+ end
236
+
237
+ @pdf.text @unicode, opts
229
238
  end
230
239
  end
231
240
 
@@ -8,6 +8,6 @@
8
8
 
9
9
  module Prawn
10
10
  class Icon
11
- VERSION = '3.1.0'
11
+ VERSION = '4.1.0'
12
12
  end
13
13
  end
@@ -18,6 +18,13 @@ describe Prawn::Icon::Interface do
18
18
 
19
19
  expect(text.font_settings.first[:size]).to eq(60)
20
20
  end
21
+
22
+ it 'should handle text options (icon height)' do
23
+ pdf.icon 'far-address-book', size: 60, size_mode: :icon_height
24
+ text = PDF::Inspector::Text.analyze(pdf.render)
25
+
26
+ expect(text.font_settings.first[:size]).to be_within(0.0001).of(58.25243)
27
+ end
21
28
  end
22
29
 
23
30
  context 'inline_format: true' do
@@ -68,7 +75,7 @@ describe Prawn::Icon::Interface do
68
75
  inspector = PDF::Inspector::Text.analyze(pdf.render)
69
76
  y = inspector.positions[1].last.round
70
77
 
71
- expect(y).to eq(723)
78
+ expect(y).to eq(722)
72
79
  end
73
80
  end
74
81
  end
@@ -154,7 +161,7 @@ describe Prawn::Icon::Interface do
154
161
  x, y = inspector.positions[0]
155
162
 
156
163
  expect(x).to eq(200)
157
- expect(y.round).to eq(90)
164
+ expect(y.round).to eq(89)
158
165
  end
159
166
 
160
167
  it 'handles final_gap: false correctly' do
@@ -267,7 +274,13 @@ describe Prawn::Icon do
267
274
  pdf.icon 'mdi-beer'
268
275
  text = PDF::Inspector::Text.analyze(pdf.render)
269
276
 
270
- expect(text.strings.first).to eq('')
277
+ # NOTE: Prawn <= 2.4.0 incorrectly handled unicode codepoints
278
+ # see: https://github.com/prawnpdf/prawn/pull/1327#issuecomment-1905817491
279
+ if Gem::Version.new(Prawn::VERSION) <= Gem::Version.new('2.4.0')
280
+ expect(text.strings.first).to eq("\u{F009}")
281
+ else
282
+ expect(text.strings.first).to eq("\u{F0098}")
283
+ end
271
284
  end
272
285
  end
273
286
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-icon
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Doyle
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-02 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -188,7 +188,7 @@ licenses:
188
188
  - GPL-3
189
189
  metadata:
190
190
  rubygems_mfa_required: 'true'
191
- post_install_message:
191
+ post_install_message:
192
192
  rdoc_options: []
193
193
  require_paths:
194
194
  - lib
@@ -203,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  - !ruby/object:Gem::Version
204
204
  version: 1.3.6
205
205
  requirements: []
206
- rubygems_version: 3.3.8
207
- signing_key:
206
+ rubygems_version: 3.5.22
207
+ signing_key:
208
208
  specification_version: 4
209
209
  summary: Provides icon fonts for PrawnPDF
210
210
  test_files: []