Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update comment
  • Loading branch information
c960657 committed Feb 7, 2022
commit ff13eaf6b26a50b8380bf40ae07c9ff620e3037f
9 changes: 6 additions & 3 deletions lib/prawn/font.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def font(name = nil, options = nil)
@font
end

# Returns the family of the current font, if the font was selected using
# a font family name, or nil, if the font was selected using a specific font
# name.
# Returns the family name of the current font, if the font was selected using
# a font family name, or nil, if the font was specified as a specific built-in
# font or a TTF file.
def font_family
@font ? @font.family : 'Helvetica'
end
Expand Down Expand Up @@ -103,6 +103,9 @@ def font_family
# the style to :italic results in italic, not bold-italic text. Use
# :bold_italic instead.
#
# Font style can only be applied, if the current font is specified using a
# font family name, not a specific built-in font or TTF file.
#
def font_style(style = nil, &block)
return @font ? @font.style : :normal if style.nil?

Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/font_metric_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(document)
def width_of(string, options)
f =
if options[:style]
# override style with :style => :boldd
# override style with :style => :bold
@document.find_font(nil, style: options[:style])
else
@document.font
Expand Down