File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,16 @@ def format_hash
225225
226226 def render
227227 @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
229238 end
230239 end
231240
Original file line number Diff line number Diff line change 1818
1919 expect ( text . font_settings . first [ :size ] ) . to eq ( 60 )
2020 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
2128 end
2229
2330 context 'inline_format: true' do
You can’t perform that action at this time.
0 commit comments