class Prawn::Text::Formatted::LineWrap
Implements individual line wrapping of formatted text.
@private
Attributes
The number of spaces in the last wrapped line. @return [Integer]
Public Instance Methods
Source
# File lib/prawn/text/formatted/line_wrap.rb, line 24 def paragraph_finished? @newline_encountered || next_string_newline? || @arranger.finished? end
Whether this line is the last line in the paragraph.
@return [Boolean]
Source
# File lib/prawn/text/formatted/line_wrap.rb, line 32 def tokenize(fragment) fragment.scan(scan_pattern(fragment.encoding)) end
Break the fragment into tokens.
@param fragment [String] @return [Array<String>]
Source
# File lib/prawn/text/formatted/line_wrap.rb, line 13 def width @accumulated_width || 0 end
The width of the last wrapped line.
@return [Number]
Source
# File lib/prawn/text/formatted/line_wrap.rb, line 47 def wrap_line(options) initialize_line(options) # rubocop: disable Lint/AssignmentInCondition while fragment = @arranger.next_string # rubocop: enable Lint/AssignmentInCondition @fragment_output = +'' fragment.lstrip! if first_fragment_on_this_line?(fragment) next if empty_line?(fragment) unless apply_font_settings_and_add_fragment_to_line(fragment) break end end @arranger.finalize_line @accumulated_width = @arranger.line_width @space_count = @arranger.space_count @arranger.line end
Work in conjunction with the {Prawn::Text::Formatted::Arranger} defined in the ‘:arranger` option to determine what formatted text will fit within the width defined by the `:width` option.
@param options [Hash{Symbol => any}] @option options :document [Prawn::Document] @option options :kerning [Boolean] @option options :width [Number] @option options :disable_wrap_by_char [Boolean] @option options :arranger [Prawn::Text::Formatted::Arranger] @return [String]