Skip to content

Commit

Permalink
allow relative font size for sub and sup to be set independently; sup…
Browse files Browse the repository at this point in the history
…port combined setting for backwards compatibility
  • Loading branch information
mojavelinux committed Feb 14, 2025
1 parent 62b5eef commit 59e008a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co

Improvements::

* allow relative font size for sub and sup to be set independently; support combined setting for backwards compatibility
* allow value of `base-font-size-min` and `<category>-font-size-min` theme keys to be relative (e.g., 0.75em) (#2547)

== 2.3.19 (2024-10-11) - @mojavelinux
Expand Down
13 changes: 9 additions & 4 deletions lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize *_args
super
@dummy_text = ?\u0000
@normalize_line_height = false
@sub_and_sup_relative_size = 0.583
@sub_relative_size = @sup_relative_size = 0.583
end

def format_array= array
Expand Down Expand Up @@ -38,13 +38,18 @@ def preview_joined_string
end

def apply_font_size size, styles
if (subscript? styles) || (superscript? styles)
if (sub = subscript? styles) || (superscript? styles)
size ||= @document.font_size
if instance_variable_defined? :@sub_and_sup_relative_size
relative_size = @sub_and_sup_relative_size
else
relative_size = sub ? @sub_relative_size : @sup_relative_size
end
if String === size
units = (size.end_with? 'em', '%') ? ((size.end_with? '%') ? '%' : 'em') : ''
size = %(#{size.to_f * @sub_and_sup_relative_size}#{units})
size = %(#{size.to_f * relative_size}#{units})
else
size *= @sub_and_sup_relative_size
size *= relative_size
end
@document.font_size(size) { yield }
elsif size
Expand Down

0 comments on commit 59e008a

Please sign in to comment.