Skip to content

Commit

Permalink
Add option to interpret size option as icon height rather than font size
Browse files Browse the repository at this point in the history
  • Loading branch information
pepijnve committed Dec 1, 2024
1 parent 788a6ce commit 27761ec
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/prawn/icon/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,17 @@ def format_hash

def render
@pdf.font(@data.path) do
@pdf.text @unicode, @options
opts = @options.dup

size_mode = opts.delete(:size_mode) || :font_size
if size_mode == :icon_size
requested_size = @options[:size] || @pdf.font_size
actual_height = @pdf.font.height_at(requested_size)
adjusted_size = requested_size / actual_height * requested_size
opts[:size] = adjusted_size
end

@pdf.text @unicode, opts
end
end

Expand Down

0 comments on commit 27761ec

Please sign in to comment.